Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Populate userform combobox with option button

I have a simple userform with a combox and two option buttons. I would
like to populate the combobox with a range if optionbutton1 is clicked
and with another range if ob2 is clicked. I keep getting a "Run time
error 13, type mismatch" message. My code is below.

Private Sub OptionButton1_Click()
UserForm1.ComboBox1.RowSource = Range("a1:a10")
End Sub

Can anyone tell me what is wrong with this? Looks legit to me.

Thanks for any help,
Greg
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,510
Default Populate userform combobox with option button

Hi Greg,

These properties are set as strings that look idnetical to the way you would
enter them in the properties dialog box.

Private Sub OptionButton1_Click()
UserForm1.ComboBox1.RowSource = "Sheet1!A1:A10"
End Sub

Private Sub OptionButton2_Click()
UserForm1.ComboBox1.RowSource = "Sheet1!B1:B10"
End Sub

--
Regards,

OssieMac


"Gig" wrote:

I have a simple userform with a combox and two option buttons. I would
like to populate the combobox with a range if optionbutton1 is clicked
and with another range if ob2 is clicked. I keep getting a "Run time
error 13, type mismatch" message. My code is below.

Private Sub OptionButton1_Click()
UserForm1.ComboBox1.RowSource = Range("a1:a10")
End Sub

Can anyone tell me what is wrong with this? Looks legit to me.

Thanks for any help,
Greg

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Populate userform combobox with option button

On Mar 12, 7:09*am, OssieMac
wrote:
Hi Greg,

These properties are set as strings that look idnetical to the way you would
enter them in the properties dialog box.

Private Sub OptionButton1_Click()
* * *UserForm1.ComboBox1.RowSource = "Sheet1!A1:A10"
End Sub

Private Sub OptionButton2_Click()
* * *UserForm1.ComboBox1.RowSource = "Sheet1!B1:B10"
End Sub

--
Regards,

OssieMac

"Gig" wrote:
I have a simple userform with a combox and two option buttons. I would
like to populate the combobox with a range if optionbutton1 is clicked
and with another range if ob2 is clicked. I keep getting a "Run time
error 13, type mismatch" message. My code is below.


Private Sub OptionButton1_Click()
UserForm1.ComboBox1.RowSource = Range("a1:a10")
End Sub


Can anyone tell me what is wrong with this? Looks legit to me.


Thanks for any help,
Greg


Thanks Ossie, but can you tell me why the code wouldn't be written
like this:

Private Sub OptionButton2_Click()
UserForm1.ComboBox1.RowSource = Sheets("sheet1").range("B1:B10")
End Sub

Thanks,
Greg
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,510
Default Populate userform combobox with option button

Hi Greg,

I can't really explain more than my previous comment "These properties are
set as strings that look identical to the way you would enter them in the
properties dialog box."
Bacically the code emulates what you would do manually.
--
Regards,

OssieMac


" wrote:

On Mar 12, 7:09 am, OssieMac
wrote:
Hi Greg,

These properties are set as strings that look idnetical to the way you would
enter them in the properties dialog box.

Private Sub OptionButton1_Click()
UserForm1.ComboBox1.RowSource = "Sheet1!A1:A10"
End Sub

Private Sub OptionButton2_Click()
UserForm1.ComboBox1.RowSource = "Sheet1!B1:B10"
End Sub

--
Regards,

OssieMac

"Gig" wrote:
I have a simple userform with a combox and two option buttons. I would
like to populate the combobox with a range if optionbutton1 is clicked
and with another range if ob2 is clicked. I keep getting a "Run time
error 13, type mismatch" message. My code is below.


Private Sub OptionButton1_Click()
UserForm1.ComboBox1.RowSource = Range("a1:a10")
End Sub


Can anyone tell me what is wrong with this? Looks legit to me.


Thanks for any help,
Greg


Thanks Ossie, but can you tell me why the code wouldn't be written
like this:

Private Sub OptionButton2_Click()
UserForm1.ComboBox1.RowSource = Sheets("sheet1").range("B1:B10")
End Sub

Thanks,
Greg

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
option button and userform question Shawn Excel Programming 1 June 29th 07 12:51 AM
Populate A Userform ComboBox mastermind Excel Programming 2 April 24th 07 09:52 PM
Using Option Button to populate formula Archgrad Excel Discussion (Misc queries) 0 August 8th 06 10:47 PM
Userform ComboBox populate using code? Marc Cowlin Excel Programming 1 July 19th 06 02:25 PM
Combobox populating based on Option Button Todd Huttenstine[_2_] Excel Programming 7 November 9th 03 10:18 PM


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

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

About Us

"It's about Microsoft Excel"