有人能告诉我下面代码中的错误在哪里吗?
是不是因为列表太长了?我不知道为什么会出现语法错误。
非常感谢您提供的任何帮助。
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim tabArray As Variant
Dim i As Long
tabArray = Array("B3","B4","G3","F7","H7","I7","J7","F8","H8","I8","J8","F9","H9","I9","J9","F10","H10","I10","J10","F11","H11","I11","J11","F12","H12","I12","J12","F13","H13","I13","J13","F14","H14","I14","J14","F15","H15","I15","J15","F19,"I19","C23","F23","C27","C29","C36","F37","I36","C37","C38","C40","C41","C42","G46","H46","G47","H47","G48","H48","C77","C80","C85","D85","C86","D86","C87","D87","C89","D89","C90","D90","C91","D91","C92","D92","C93","D93","C94","D94","C95","D95","C96","D96","G90","J90","G91","J91","G92","J92","G93","J93","G94","J94","G95","J95","C99","C103","C104","C107","C111","C115","D115","H115","C116","D116","H116","C117","D117","H117","C118","D118","H118","C119","D119","H119","A124","A125","A126","A127","A128","A129","A130","A131","A132","A133","A134","A135","A136","A137")
Application.ScreenUpdating = False
For i = LBound(tabArray) To UBound(tabArray)
If tabArray(i) = Target.Address(0, 0) Then
If i = UBound(tabArray) Then
Me.Range(tabArray(LBound(tabArray))).Select
Else
Me.Range(tabArray(i + 1)).Select
End If
End If
Next i
Application.ScreenUpdating = True
End Sub
答案1
缺少结束双引号:
,"F19,"I19",
我修好了它:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim tabArray As Variant
Dim i As Long
tabArray = Array("B3","B4","G3","F7","H7","I7","J7","F8","H8","I8","J8","F9","H9","I9","J9","F10","H10","I10","J10","F11","H11","I11","J11","F12","H12","I12","J12","F13","H13","I13","J13","F14","H14","I14","J14","F15","H15","I15","J15","F19","I19","C23","F23","C27","C29","C36","F37","I36","C37","C38","C40","C41","C42","G46","H46","G47","H47","G48","H48","C77","C80","C85","D85","C86","D86","C87","D87","C89","D89","C90","D90","C91","D91","C92","D92","C93","D93","C94","D94","C95","D95","C96","D96","G90","J90","G91","J91","G92","J92","G93","J93","G94","J94","G95","J95","C99","C103","C104","C107","C111","C115","D115","H115","C116","D116","H116","C117","D117","H117","C118","D118","H118","C119","D119","H119","A124","A125","A126","A127","A128","A129","A130","A131","A132","A133","A134","A135","A136","A137")
Application.ScreenUpdating = False
For i = LBound(tabArray) To UBound(tabArray)
If tabArray(i) = Target.Address(0, 0) Then
If i = UBound(tabArray) Then
Me.Range(tabArray(LBound(tabArray))).Select
Else
Me.Range(tabArray(i + 1)).Select
End If
End If
Next i
Application.ScreenUpdating = True
End Sub