Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 78
Default How can Rowsource be used for a combobox on a form?

I am breaking this question out of the other thread so its visible
better ;)


I am now (trying) to use Rowsource to select the range for
the drop down menu on a form that is macro started.

I need to adjust the rnage of the combobox based on the amount of cells
I have (varies all the time).

Now the problem is that if I select rowsource before I open the form it
gives an error and otherwiese the dropdown menu wont adjust its size
until after the user clicks somehting..

How can I use the rowsource for a combox command before the form is
visible?

Thanks,

Matt

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 78
Default How can Rowsource be used for a combobox on a form?

I use:

MainMenu.Show

to bring up the form.

I cant use rowsource before MainMenu.Show or it gives an error. I cant
use it after MainMenu.Show because then the form is already there and
the rows not adjusted ...

Matt

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 179
Default How can Rowsource be used for a combobox on a form?

Matt wrote:
I use:

MainMenu.Show

to bring up the form.

I cant use rowsource before MainMenu.Show or it gives an error. I cant
use it after MainMenu.Show because then the form is already there and
the rows not adjusted ...

Matt:

I think you can use

Load MainMenu

MainMenu.Combobox1.RowSource = "Whatever"

MainMenu.Show

However, you shouldn't ever use RowSource. See here

http://www.dicks-blog.com/archives/2...stboxcombobox/


--
Dick Kusleika
MVP - Excel
Daily Dose of Excel
http://www.dicks-blog.com


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default How can Rowsource be used for a combobox on a form?

Load MainMenu
With Worksheets("Sheet1")
set rng = .Range(.Cells(1,1),.Cells(1,1).End(xldown))
End With
MainMenu.Combobox1.Rowsource = rng.Address(External:=True)
MainMenu.Show

although I have never had trouble with
With Worksheets("Sheet1")
set rng = .Range(.Cells(1,1),.Cells(1,1).End(xldown))
End With
MainMenu.Combobox1.Rowsource = rng.Address(External:=True)
MainMenu.Show

As soon as you reference MainMenu, it is loaded.

--
Regards,
Tom Ogilvy



"Matt" wrote in message
oups.com...
I use:

MainMenu.Show

to bring up the form.

I cant use rowsource before MainMenu.Show or it gives an error. I cant
use it after MainMenu.Show because then the form is already there and
the rows not adjusted ...

Matt



  #5   Report Post  
Posted to microsoft.public.excel.programming
baj baj is offline
external usenet poster
 
Posts: 24
Default How can Rowsource be used for a combobox on a form?

Hi,

Suppose the list of items you're after are in column A, and suppose
that your list will never be longer than 100 items, which is very
reasonable for a picklist...

Than you can select a range in column A that is bigger than the longest
expected length and add the items untill you meet a blank cell...

This is the startup-procedure for the Userform Try1 that fills Listbox1
with the items found in tha range
ThisWorkbook.Sheets("1").Range("a1:a200")

Private Sub UserForm_Activate()
Dim list1 As Variant

With ThisWorkbook.Sheets("1")
list1 = .Range("a1:a200")
End With

i = 1
For i = 1 To 200
If list1(i, 1) = "" Then
Exit Sub
End If
With Try1.ListBox1
..AddItem (list1(i, 1))
End With
Next

End Sub


Ofcourse you can refine this further...

Bye
Baj



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 78
Default How can Rowsource be used for a combobox on a form?

Works like a charm! Thanks to all the guys who helped !!!!!!! :)

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
RowSource for Sheet ComboBox Minitman Excel Worksheet Functions 3 March 24th 08 09:43 PM
How do I set the rowsource for a ComboBox for a dynamic list? ndm berry[_2_] Excel Programming 4 September 29th 05 01:11 PM
combobox rowsource as code JasonSelf[_20_] Excel Programming 1 September 13th 05 08:44 PM
How Do I Load A ComboBox RowSource From The Results Of Another ComboBox Minitman[_4_] Excel Programming 3 October 26th 04 07:58 PM
combobox rowsource Newbie Excel Programming 1 September 8th 04 12:21 PM


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