Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 360
Default trouble loading a range into a comboBox

Can you tell me why when I run this userform that it erases the values in the
range A1:A12?
The userform initialize procedure runs but it erases the values in the cells
A1:A12 and it doens't have the list in the comboBox but other than that it
runs.

Private Sub UserForm_Initialize()

ThisWorkbook.Worksheets("patients").Range("A1:A12" ) = Me.ComboBox2.Value

End Sub

And I ran it several times and get the same results.

What am I missing?
tnx,
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default trouble loading a range into a comboBox

your telling excel to set the range A1:a12 = to the form's combobox value. if
the combobox is empty, range("A1:A12") will be empty.

--


Gary


"Janis" wrote in message
...
Can you tell me why when I run this userform that it erases the values in the
range A1:A12?
The userform initialize procedure runs but it erases the values in the cells
A1:A12 and it doens't have the list in the comboBox but other than that it
runs.

Private Sub UserForm_Initialize()

ThisWorkbook.Worksheets("patients").Range("A1:A12" ) = Me.ComboBox2.Value

End Sub

And I ran it several times and get the same results.

What am I missing?
tnx,



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 735
Default trouble loading a range into a comboBox

You are currently forcing an empty ComboBox value into A1:A12, even if you
reversed the assignment it would still not load the ComboBox......use the
following to achieve that.

Dim c As Range
ComboBox1.Clear
For Each c In Worksheets("patients").Range("A1:A12")
ComboBox1.AddItem c.Value
Next c

--

Regards,
Nigel




"Janis" wrote in message
...
Can you tell me why when I run this userform that it erases the values in
the
range A1:A12?
The userform initialize procedure runs but it erases the values in the
cells
A1:A12 and it doens't have the list in the comboBox but other than that it
runs.

Private Sub UserForm_Initialize()

ThisWorkbook.Worksheets("patients").Range("A1:A12" ) = Me.ComboBox2.Value

End Sub

And I ran it several times and get the same results.

What am I missing?
tnx,


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 812
Default trouble loading a range into a comboBox

Try this.

Private Sub UserForm_Initialize()
ComboBox2.RowSource= "patients!A1:A12"
End Sub

Hth,
Merjet

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 360
Default trouble loading a range into a comboBox

Nigel
Thanks for the answer. It really is urgent. Helped immensely. :)

"Nigel" wrote:

You are currently forcing an empty ComboBox value into A1:A12, even if you
reversed the assignment it would still not load the ComboBox......use the
following to achieve that.

Dim c As Range
ComboBox1.Clear
For Each c In Worksheets("patients").Range("A1:A12")
ComboBox1.AddItem c.Value
Next c

--

Regards,
Nigel




"Janis" wrote in message
...
Can you tell me why when I run this userform that it erases the values in
the
range A1:A12?
The userform initialize procedure runs but it erases the values in the
cells
A1:A12 and it doens't have the list in the comboBox but other than that it
runs.

Private Sub UserForm_Initialize()

ThisWorkbook.Worksheets("patients").Range("A1:A12" ) = Me.ComboBox2.Value

End Sub

And I ran it several times and get the same results.

What am I missing?
tnx,




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default trouble loading a range into a comboBox

Check your first post, too.

Janis wrote:

Can you tell me why when I run this userform that it erases the values in the
range A1:A12?
The userform initialize procedure runs but it erases the values in the cells
A1:A12 and it doens't have the list in the comboBox but other than that it
runs.

Private Sub UserForm_Initialize()

ThisWorkbook.Worksheets("patients").Range("A1:A12" ) = Me.ComboBox2.Value

End Sub

And I ran it several times and get the same results.

What am I missing?
tnx,


--

Dave Peterson
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
trouble loading excel files Lonnie Excel Discussion (Misc queries) 0 February 5th 09 05:28 PM
Trouble with a ComboBox on a UserForm ryguy7272 Excel Discussion (Misc queries) 1 February 20th 08 09:02 PM
Loading Combobox, but avoiding duplicates Dan Excel Programming 2 May 8th 07 06:15 PM
Loading sheet names in Combobox Sige Excel Programming 5 September 16th 05 05:09 PM
Maps.........Having Trouble Loading things grasshopper Excel Worksheet Functions 1 November 3rd 04 03:29 PM


All times are GMT +1. The time now is 10:03 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"