Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default 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.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 422
Default 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.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 422
Default 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.


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default 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


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 09:25 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"