Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 80
Default Pass parameter to a form and then open it?

[Excel 2000]
Is there a combobox-style Inputbox hidden away in Excel anywhere? Or is it
possible to pass parameters to a form as it loads?

I have a macro, which in the middle of the code requires input from the
user.
Presents a form with a combobox on it.
The combobox is filled with a list - lets call it MyList.
Based on the value of a variable in the macro (call it MyValue), a
specific entry in the list is already selected.
The user then either accepts the offered value or selects a different
value from the list.
The macro then stores the result in a variable (MyResult) and continues
the code.

I don't want to use a standard inputbox because many of the entries are
long strings, and it will be irritating to type them in.
But using a form is complicated by the need to pass the default list
entry to the form.

I hope I've explained my problem clearly - can anyone suggest a solution?

Darren



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Pass parameter to a form and then open it?

Darren,

Here is an example of some code that loads a form combobox from a worksheet
range, and then selects an item based jupon a value in B1.

Load UserForm1
With UserForm1
.ComboBox1.RowSource = Range("A1:A10").Address(False, False)
.ComboBox1.ListIndex = Range("B1").Value
.Show
End With

Post back if you need further explanation .

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Darren Hill" wrote in message
...
[Excel 2000]
Is there a combobox-style Inputbox hidden away in Excel anywhere? Or is it
possible to pass parameters to a form as it loads?

I have a macro, which in the middle of the code requires input from the
user.
Presents a form with a combobox on it.
The combobox is filled with a list - lets call it MyList.
Based on the value of a variable in the macro (call it MyValue), a
specific entry in the list is already selected.
The user then either accepts the offered value or selects a different
value from the list.
The macro then stores the result in a variable (MyResult) and

continues
the code.

I don't want to use a standard inputbox because many of the entries

are
long strings, and it will be irritating to type them in.
But using a form is complicated by the need to pass the default list
entry to the form.

I hope I've explained my problem clearly - can anyone suggest a solution?

Darren





  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Pass parameter to a form and then open it?

Here is an adaptation of Bob's code that uses your examples:

Load UserForm1
With UserForm1
.ComboBox1. = Range("MyList")
.ComboBox1.Value = MyValue
.Show
msgbox .Combobox1.Value
End With
Unload Userform1

in userform1

You need to disable the users ability to close userform1 except by using a
close button you provide. This can be done with the queryclose event. then
have you button hide the userform so you can get the value of the combobox,
or as an alternate approach, you can use a public variable to capture the
selection using the click event.

--
Regards,
Tom Ogilvy

Darren Hill wrote in message
...
[Excel 2000]
Is there a combobox-style Inputbox hidden away in Excel anywhere? Or is it
possible to pass parameters to a form as it loads?

I have a macro, which in the middle of the code requires input from the
user.
Presents a form with a combobox on it.
The combobox is filled with a list - lets call it MyList.
Based on the value of a variable in the macro (call it MyValue), a
specific entry in the list is already selected.
The user then either accepts the offered value or selects a different
value from the list.
The macro then stores the result in a variable (MyResult) and

continues
the code.

I don't want to use a standard inputbox because many of the entries

are
long strings, and it will be irritating to type them in.
But using a form is complicated by the need to pass the default list
entry to the form.

I hope I've explained my problem clearly - can anyone suggest a solution?

Darren





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 80
Default Pass parameter to a form and then open it?

Thanks Tom and Bob, that's exactly what I needed.
Somehow, although I use Unload a lot, I had overlooked the Load Userform
method :)
I had come up with a workaround using public variables but I like this
method better (along with the form.hide method Tom suggests to finish off
the routine - I doubt that would have occurred to me).

--
Darren
"Tom Ogilvy" wrote in message
...
Here is an adaptation of Bob's code that uses your examples:

Load UserForm1
With UserForm1
.ComboBox1. = Range("MyList")
.ComboBox1.Value = MyValue
.Show
msgbox .Combobox1.Value
End With
Unload Userform1

in userform1

You need to disable the users ability to close userform1 except by using a
close button you provide. This can be done with the queryclose event.

then
have you button hide the userform so you can get the value of the

combobox,
or as an alternate approach, you can use a public variable to capture the
selection using the click event.

--
Regards,
Tom Ogilvy

Darren Hill wrote in message
...
[Excel 2000]
Is there a combobox-style Inputbox hidden away in Excel anywhere? Or is

it
possible to pass parameters to a form as it loads?

I have a macro, which in the middle of the code requires input from the
user.
Presents a form with a combobox on it.
The combobox is filled with a list - lets call it MyList.
Based on the value of a variable in the macro (call it MyValue), a
specific entry in the list is already selected.
The user then either accepts the offered value or selects a

different
value from the list.
The macro then stores the result in a variable (MyResult) and

continues
the code.

I don't want to use a standard inputbox because many of the entries

are
long strings, and it will be irritating to type them in.
But using a form is complicated by the need to pass the default list
entry to the form.

I hope I've explained my problem clearly - can anyone suggest a

solution?

Darren







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
pass parameter to access query Bill Manville Links and Linking in Excel 4 May 1st 23 03:45 AM
Pass date parameter into MS Query Richard Edwards Excel Discussion (Misc queries) 2 June 20th 08 11:43 AM
Is it possible to pass a parameter into IN operator in Query? DennisS Excel Discussion (Misc queries) 0 June 26th 07 09:27 AM
How to: Pass Command Line Parameter ??? Webtest Excel Worksheet Functions 0 October 24th 05 05:27 PM
How to pass a workshhet name as a parameter into a subroutine ? yigalb Excel Discussion (Misc queries) 4 January 9th 05 10:28 AM


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