ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   plz plz help me out with this (https://www.excelbanter.com/excel-programming/386969-plz-plz-help-me-out.html)

ayan[_2_]

plz plz help me out with this
 
I have tried lots of options to populate a combobox from a range but
it just wont happen I dont know why . Am at my wits end. This is one
of the options I tried

Private Sub UserForm_Initialize()
Dim emp As Range
emp =
Workbooks("test.xls").Worksheets("Sheet2").Range(" A2").End(xlDown)
For Each Cell In emp
If Cell.Value < "" Then
ComboBox1.AddItem Cell.Value
End If
Next
ComboBox1.Value = "Please Select"
End Sub

Can someone please please help me out. I dont know what to do.
Tried rowsource, list everything. Nothing works.


JMay

plz plz help me out with this
 
You need to use Set before emp;
and (Watch for word-wrap below)

Private Sub UserForm_Initialize()
Dim emp As Range
Set emp = Worksheets("Sheet1").Range(Cells(2, 1),
Cells(Range("A2").End(xlDown).Row, 1))
For Each Cell In emp
If Cell.Value < "" Then
ComboBox1.AddItem Cell.Value
End If
Next
'ComboBox1.Value = "Please Select"
End Sub

"ayan" wrote in message
oups.com:

I have tried lots of options to populate a combobox from a range but
it just wont happen I dont know why . Am at my wits end. This is one
of the options I tried

Private Sub UserForm_Initialize()
Dim emp As Range
emp =
Workbooks("test.xls").Worksheets("Sheet2").Range(" A2").End(xlDown)
For Each Cell In emp
If Cell.Value < "" Then
ComboBox1.AddItem Cell.Value
End If
Next
ComboBox1.Value = "Please Select"
End Sub

Can someone please please help me out. I dont know what to do.
Tried rowsource, list everything. Nothing works.



JMay

plz plz help me out with this
 
WATCH OU !! - I omitted your wb reference and I changed your sheetname -
You need to change back to your specs,,


"JMay" wrote in message
:

You need to use Set before emp;
and (Watch for word-wrap below)

Private Sub UserForm_Initialize()
Dim emp As Range
Set emp = Worksheets("Sheet1").Range(Cells(2, 1),
Cells(Range("A2").End(xlDown).Row, 1))
For Each Cell In emp
If Cell.Value < "" Then
ComboBox1.AddItem Cell.Value
End If
Next
'ComboBox1.Value = "Please Select"
End Sub

"ayan" wrote in message
oups.com:

I have tried lots of options to populate a combobox from a range but
it just wont happen I dont know why . Am at my wits end. This is one
of the options I tried

Private Sub UserForm_Initialize()
Dim emp As Range
emp =
Workbooks("test.xls").Worksheets("Sheet2").Range(" A2").End(xlDown)
For Each Cell In emp
If Cell.Value < "" Then
ComboBox1.AddItem Cell.Value
End If
Next
ComboBox1.Value = "Please Select"
End Sub

Can someone please please help me out. I dont know what to do.
Tried rowsource, list everything. Nothing works.



ayan[_2_]

plz plz help me out with this
 
On Apr 6, 5:14 pm, "JMay" wrote:
You need to use Set before emp;
and (Watch for word-wrap below)

Private Sub UserForm_Initialize()
Dim emp As Range
Set emp = Worksheets("Sheet1").Range(Cells(2, 1),
Cells(Range("A2").End(xlDown).Row, 1))
For Each Cell In emp
If Cell.Value < "" Then
ComboBox1.AddItem Cell.Value
End If
Next
'ComboBox1.Value = "Please Select"
End Sub

"ayan" wrote in message

oups.com:



I have tried lots of options to populate a combobox from a range but
it just wont happen I dont know why . Am at my wits end. This is one
of the options I tried


Private Sub UserForm_Initialize()
Dim emp As Range
emp =
Workbooks("test.xls").Worksheets("Sheet2").Range(" A2").End(xlDown)
For Each Cell In emp
If Cell.Value < "" Then
ComboBox1.AddItem Cell.Value
End If
Next
ComboBox1.Value = "Please Select"
End Sub


Can someone please pleasehelpmeout. I dont know what to do.
Tried rowsource, list everything. Nothing works.- Hide quoted text -


- Show quoted text -




Thanks a lot Jmay, the code works perfectly. You just saved me, I am
doing my internship & have to get a sw working & couldn't get past the
first hurdle.

If its not too much trouble could you explain this line in your code

Set emp = Worksheets("Sheet1").Range(Cells(2, 1),
Cells(Range("A2").End(xlDown).Row, 1))

I understand about the Set part but dont understand why Cells have to
be referenced like that. This might help me in my programming & wont
require me to ask your help again & again. Whats wrong with the way I
used the Cells thing, it took only the last row of info from my range
and the code for that was from a book??

Thanks a lot again, this really is a great community & u ppl are
awesome




All times are GMT +1. The time now is 06:02 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com