Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Adding WorksheetData to a ComboBox on a form?

Hi Everyone,

I am a real novice and am having a difficult time with coding. I
agreed to make an Excel program to track adverse drug experiences for
work and I would like to fill a ComboBox on a form I created with data
from a single column on a worksheet.

Here is the coding for my form:

Private Sub ComboBox1_Change()
Dim i As Long
Dim S1 As Worksheet

Set S1 = Sheets("DataEntry")

S1.Select
Range("A2").Select
For i = 2 To Cells(Rows.Count, 1).End(xlUp).Row
UserForm6.ComboBox1.AddItem S1.Cells(i, 1).Value
Next i
End Sub


Is there something goofy with my coding?! It seems to run alright, but
there are no values listed in the drop-down box. PLEASE HELP!!! I've
wasted too much time with something that is probably pretty easy to
solve.

Thanks,
Jeff

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 104
Default Adding WorksheetData to a ComboBox on a form?

Hi Jeff,
You nearly had your code right, it just needs a few changes. Plus this
code should be run in the UserForm_Initialize() event procedure. See the
code below. Enjoy....

Rick


Private Sub UserForm_Initialize()
Dim i As Long
Dim S1 As Worksheet

Set S1 = Worksheets("DataEntry")

' S1.Select (not required)
' Range("A2").Select (not required)
' For i = 2 To Cells(Rows.Count, 1).End(xlUp).Row (see next line)

For i = 2 To S1.Range("A2").End(xlDown).Row
UserForm6.ComboBox1.AddItem S1.Cells(i, 1).Value
Next i

End Sub



wrote in message
oups.com...
Hi Everyone,

I am a real novice and am having a difficult time with coding. I
agreed to make an Excel program to track adverse drug experiences for
work and I would like to fill a ComboBox on a form I created with data
from a single column on a worksheet.

Here is the coding for my form:

Private Sub ComboBox1_Change()
Dim i As Long
Dim S1 As Worksheet

Set S1 = Sheets("DataEntry")

S1.Select
Range("A2").Select
For i = 2 To Cells(Rows.Count, 1).End(xlUp).Row
UserForm6.ComboBox1.AddItem S1.Cells(i, 1).Value
Next i
End Sub


Is there something goofy with my coding?! It seems to run alright, but
there are no values listed in the drop-down box. PLEASE HELP!!! I've
wasted too much time with something that is probably pretty easy to
solve.

Thanks,
Jeff



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Adding WorksheetData to a ComboBox on a form?


Hello Jeff,

To start with, you have your code in the wrong event. It should b
placed in the Private Sub UserForm_Activate() event module.

_______________________________

Private Sub UserForm_Activate()
Dim i As Long
Dim S1 As Worksheet

Set S1 = Sheets("DataEntry")

For i = 2 To S1.Cells(Rows.Count, 1).End(xlUp).Row
UserForm6.ComboBox1.AddItem S1.Cells(i, 1).Value
Next i
End Sub
_______________________________

Sincerely,
Leith Ros

--
Leith Ros
-----------------------------------------------------------------------
Leith Ross's Profile: http://www.excelforum.com/member.php...fo&userid=1846
View this thread: http://www.excelforum.com/showthread.php?threadid=50882

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Adding WorksheetData to a ComboBox on a form?

Hey Rick,

Thank you very much for your help! I was spinning my wheels and going
crazy...

Take care,
Jeff

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Adding WorksheetData to a ComboBox on a form?

Hi Leith,

Thank you very much for responding so quickly! I was so frustrated
with not being able continue my coding. Very interesting that there
were two solutions to my problem.

Take care,
Jeff



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Adding WorksheetData to a ComboBox on a form?



"Rick Hansen" wrote:

Hi Jeff,
You nearly had your code right, it just needs a few changes. Plus this
code should be run in the UserForm_Initialize() event procedure. See the
code below. Enjoy....

Rick


Private Sub UserForm_Initialize()
Dim i As Long
Dim S1 As Worksheet

Set S1 = Worksheets("DataEntry")

' S1.Select (not required)
' Range("A2").Select (not required)
' For i = 2 To Cells(Rows.Count, 1).End(xlUp).Row (see next line)

For i = 2 To S1.Range("A2").End(xlDown).Row
UserForm6.ComboBox1.AddItem S1.Cells(i, 1).Value
Next i

End Sub



wrote in message
oups.com...
Hi Everyone,

I am a real novice and am having a difficult time with coding. I
agreed to make an Excel program to track adverse drug experiences for
work and I would like to fill a ComboBox on a form I created with data
from a single column on a worksheet.

Here is the coding for my form:

Private Sub ComboBox1_Change()
Dim i As Long
Dim S1 As Worksheet

Set S1 = Sheets("DataEntry")

S1.Select
Range("A2").Select
For i = 2 To Cells(Rows.Count, 1).End(xlUp).Row
UserForm6.ComboBox1.AddItem S1.Cells(i, 1).Value
Next i
End Sub


Is there something goofy with my coding?! It seems to run alright, but
there are no values listed in the drop-down box. PLEASE HELP!!! I've
wasted too much time with something that is probably pretty easy to
solve.

Thanks,
Jeff




  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Adding WorksheetData to a ComboBox on a form?

Hi Rick,

I was just reading your reply to Jeff re. populating a combox from a single
column on a worksheet. I have been trying to adapt this so that i can
populate two comboboxes on the same user form from two separate columns on
the same worksheet. I am having no luck!!!

Would appreciate if you could advise.

Thanks,

Ciara

"Rick Hansen" wrote:

Hi Jeff,
You nearly had your code right, it just needs a few changes. Plus this
code should be run in the UserForm_Initialize() event procedure. See the
code below. Enjoy....

Rick


Private Sub UserForm_Initialize()
Dim i As Long
Dim S1 As Worksheet

Set S1 = Worksheets("DataEntry")

' S1.Select (not required)
' Range("A2").Select (not required)
' For i = 2 To Cells(Rows.Count, 1).End(xlUp).Row (see next line)

For i = 2 To S1.Range("A2").End(xlDown).Row
UserForm6.ComboBox1.AddItem S1.Cells(i, 1).Value
Next i

End Sub



wrote in message
oups.com...
Hi Everyone,

I am a real novice and am having a difficult time with coding. I
agreed to make an Excel program to track adverse drug experiences for
work and I would like to fill a ComboBox on a form I created with data
from a single column on a worksheet.

Here is the coding for my form:

Private Sub ComboBox1_Change()
Dim i As Long
Dim S1 As Worksheet

Set S1 = Sheets("DataEntry")

S1.Select
Range("A2").Select
For i = 2 To Cells(Rows.Count, 1).End(xlUp).Row
UserForm6.ComboBox1.AddItem S1.Cells(i, 1).Value
Next i
End Sub


Is there something goofy with my coding?! It seems to run alright, but
there are no values listed in the drop-down box. PLEASE HELP!!! I've
wasted too much time with something that is probably pretty easy to
solve.

Thanks,
Jeff




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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Form Help - ComboBox - VBA jlclyde Excel Discussion (Misc queries) 5 January 13th 09 08:20 PM
link form combobox hngo Excel Worksheet Functions 0 July 28th 06 03:38 PM
How can Rowsource be used for a combobox on a form? Matt[_33_] Excel Programming 5 October 25th 05 03:00 AM
VBA Form ComboBox question WTG Excel Worksheet Functions 3 February 26th 05 04:27 PM
VBA Form ComboBox question WTG Excel Programming 3 February 26th 05 03:19 PM


All times are GMT +1. The time now is 07:12 PM.

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"