Lost_User21
New Member
- Joined
- Feb 28, 2021
- Messages
- 2
- Office Version
- 2019
- Platform
- Windows
Hi all, I am new to this and learning VBA. This may be basic but I can't get it -
I have UserForm1 that has ComboBox1 to select an address from a table in Sheet2.
I try to list data from Sheet2 but it just lists Sheet1 (or nothing). I used some lines I found on a video and it just works for data in Sheet1
Private Sub UserForm_Initialize()
Dim cntr As Integer
cntr = Application.WorksheetFunction.CountA(Range("A:A"))
For i = 1 to cntr
Me.ComboBox1.AddItem Cells (i, 1)
Next i
End Sub
I tried Sheet2.Range("A:A")) and worksheets("Sheet2").Range("A:A") but I can't get Sheet2.
I know its a matter of referencing Shee2 but I'm wracking my head.
Image is Sheet2 example
I have UserForm1 that has ComboBox1 to select an address from a table in Sheet2.
I try to list data from Sheet2 but it just lists Sheet1 (or nothing). I used some lines I found on a video and it just works for data in Sheet1
Private Sub UserForm_Initialize()
Dim cntr As Integer
cntr = Application.WorksheetFunction.CountA(Range("A:A"))
For i = 1 to cntr
Me.ComboBox1.AddItem Cells (i, 1)
Next i
End Sub
I tried Sheet2.Range("A:A")) and worksheets("Sheet2").Range("A:A") but I can't get Sheet2.
I know its a matter of referencing Shee2 but I'm wracking my head.
Image is Sheet2 example