Run-time error '-2147024809 (80070057) could not find the specified object.
to shorten the repetition If, I use the code:
Sub kodeaktif()
Dim ni, nu, na As String
Dim ime As Long
nu = True
ni = False
na = vbNullString
For Ime = 1 To 20 'jika sumber tidak ada maka terkunci
Controls("Image" & Ime).Visible = IIf(Sheets("VIP").Cells(34, Ime + 3) <> na, ni, nu)
Next Ime
End Sub
but this code can not be processed in excel vba. anyone know why? give me the alternative
UPDATE. code userform:
Private Sub userform_initialize()
fRef.Caption = "xxxxxxx"
Sheets("VIP").Select
Set ws = Sheets("VIP")
ListBox2.ColumnWidths = "40;0;0;50;0;0;50"
ListBox2.columnCount = 7
ListBox2.List = ws.Range("q28:W" & [q300].End(3).Row).Value
ListBox3.ColumnWidths = "40;0;0;50;0;0;50"
ListBox3.columnCount = 7
ListBox3.List = ws.Range("z28:AF" & [z300].End(3).Row).Value
Call kodeaktif
End Sub
Private Sub ListBox2_Click()
Dim say As Long, a As Byte
Set ws = Sheets("VIP")
Label8 = ListBox2.ListIndex + 1
yay = Label8.Caption
fMenu.TextBox4 = ws.Range("T" & yay + 27)
fMenu.TextBox6 = ws.Range("W" & yay + 27)
End Sub
Private Sub ListBox3_Click()
Dim say As Long, a As Byte
Set ws = Sheets("VIP")
Label9 = ListBox3.ListIndex + 1
yay = Label9.Caption
fMenu.TextBox4 = Format(ws.Range("AC" & yay + 27), "0.00000000")
fMenu.TextBox6 = Format(ws.Range("AF" & yay + 27), "0.00000000")
End Sub
.....