我目前有下面的代码。“ins”目前只能有七个值,因此代码就足够了,但是到下个月我被告知将有超过 900 个值!
我假设我可以使用某种数组,而不是编写另外 900 个案例语句。任何人都可以在正确的方向上轻推我吗?
Private Sub test()
Dim i As Long
Dim lr As Long
Dim ins As String
lr = Range("A" & Rows.Count).End(xlUp).Row
For i = 6 To lr
Select Case Cells(i, 20)
Case Is = ""
ins = Mid(Cells(i, 11), 14, 2)
Select Case Cells(i, 10)
Case "Inx", "ComInx"
Select Case Cells(i, 9)
Case "EINX"
Select Case ins
Case "LD"
Cells(i, 9).Value = "SR"
Case "GP"
Cells(i, 9).Value = "GAMA"
Case "AV"
Cells(i, 9).Value = "NU"
Case "AX"
Cells(i, 9).Value = "AXC"
Case "MZ"
Cells(i, 9).Value = "MZE"
Case "AD"
Cells(i, 9).Value = "AGD"
Case "AG"
Cells(i, 9).Value = "AG"
End Select
End Select
End Select
End Select
Next
End Sub