nuttycow13
New Member
- Joined
- Feb 6, 2012
- Messages
- 47
I have written vba script but keep getting this error message:
Run-Time error '1004': Method 'Ranger' of Object'_Worksheet' Failed.
Can anyone tell me what's wrong with this code:
Private Sub UserForm_Initialize()
Dim Site As Range
Dim Location As Range
Dim Printer_Type As Range
Dim ws As Worksheet
Set ws = Worksheets("LookUp USSD")
For Each Site In ws.Range("Site")
With Me.Sitebox
.AddItem Site.Value
End With
Next Site
For Each Location In ws.Range("location")
With Me.Locationbox
.AddItem Location.Value
End With
Next Location
For Each Printer_Type In ws.Range("Printer_Type")
With Me.Printer_Type_box
.AddItem Printer_Type.Value
End With
Next Printer_Type
End Sub
Site, Location and Printer_Type are all combobox's, i think the error is the line i have made bold but could be wrong
if anyone could help me that would be brilliant as its really starting to bug me.
Thank you in advance.
Run-Time error '1004': Method 'Ranger' of Object'_Worksheet' Failed.
Can anyone tell me what's wrong with this code:
Private Sub UserForm_Initialize()
Dim Site As Range
Dim Location As Range
Dim Printer_Type As Range
Dim ws As Worksheet
Set ws = Worksheets("LookUp USSD")
For Each Site In ws.Range("Site")
With Me.Sitebox
.AddItem Site.Value
End With
Next Site
For Each Location In ws.Range("location")
With Me.Locationbox
.AddItem Location.Value
End With
Next Location
For Each Printer_Type In ws.Range("Printer_Type")
With Me.Printer_Type_box
.AddItem Printer_Type.Value
End With
Next Printer_Type
End Sub
Site, Location and Printer_Type are all combobox's, i think the error is the line i have made bold but could be wrong
if anyone could help me that would be brilliant as its really starting to bug me.
Thank you in advance.
Last edited: