RAKESH230583
New Member
- Joined
- Jan 10, 2011
- Messages
- 46
Hi,
I have one Excel Userform, Under which I have 7 Different comboBox and for source for the every single combobox I had used the below quoted VBA under Private Sub UserForm_Activate()
Under Sheet2("Source") - under column range A:G - I had listed all the value which I required to show under each combobox.
Below quoted VBA code works fine for me - But Is there any possibility that instead of using such big and complicated code I can use the simple and short code which will give me the same results ?
I have one Excel Userform, Under which I have 7 Different comboBox and for source for the every single combobox I had used the below quoted VBA under Private Sub UserForm_Activate()
Under Sheet2("Source") - under column range A:G - I had listed all the value which I required to show under each combobox.
Below quoted VBA code works fine for me - But Is there any possibility that instead of using such big and complicated code I can use the simple and short code which will give me the same results ?
Code:
Private Sub UserForm_Activate()
Dim Ws As Worksheet
Dim i As Integer
Set Ws = ThisWorkbook.Sheets("Source")
Me.ComboBox1.Clear
For i = 2 To Ws.Range("A" & Application.Rows.Count).End(xlUp).Row
Me.ComboBox1.AddItem Ws.Range("A" & i).Value
Next I
Me.ComboBox2.Clear
For i = 2 To Ws.Range("B" & Application.Rows.Count).End(xlUp).Row
Me.ComboBox2.AddItem Ws.Range("B" & i).Value
Next I
Me.ComboBox3.Clear
For i = 2 To Ws.Range("C" & Application.Rows.Count).End(xlUp).Row
Me.ComboBox3.AddItem Ws.Range("C" & i).Value
Next I
Me.ComboBox4.Clear
For i = 2 To Ws.Range("D" & Application.Rows.Count).End(xlUp).Row
Me.ComboBox4.AddItem Ws.Range("D" & i).Value
Next I
Me.ComboBox5.Clear
For i = 2 To Ws.Range("E" & Application.Rows.Count).End(xlUp).Row
Me.ComboBox5.AddItem Ws.Range("E" & i).Value
Next I
Me.ComboBox6.Clear
For i = 2 To Ws.Range("F" & Application.Rows.Count).End(xlUp).Row
Me.ComboBox6.AddItem Ws.Range("F" & i).Value
Next I
Me.ComboBox7.Clear
For i = 2 To Ws.Range("G" & Application.Rows.Count).End(xlUp).Row
Me.ComboBox7.AddItem Ws.Range("G" & i).Value
Next I
Me.Date_Picker.Value = Date
End Sub
Last edited by a moderator: