多個單元格引用單元格R1以間接查找其他四個表格之一。這些工作表被命名爲week1,week2,week3和week4。 我正在尋找的是當我點擊按鈕X時,我的參考單元從第1周變爲第2周。每次點擊它應該提前到第4週迴到第1周的程度。excel vba單元格值循環步驟
我目前的斷碼讀取:
'Change the week number in cell R1
week = Range("R1")
If week = week1 Then
Range("R1").Value = week2
Else
If week = week2 Then
Range("R1").Value = week3
Else
If week = week3 Then
Range("R1").Value = week4
Else
If week = week4 Then
Range("R1").Value = week1
End If
End If
End If
End If
Application.ScreenUpdating = True 'Turns viewing function back on so the spreadsheet is usable.
End Sub
輸入錯誤我前僱主代碼Dim week1作爲Sting week1 =「week1」等等 – GeoHoward
你的代碼很好,只要用引號括起'week1'等。 '「week1」'),但是對於更高效的代碼,請參閱Jeeped簡短回答。 – EEM