Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default userform and variable

anyway to set a userform name to a variable i can use with <variable name
instead of with userform1, with userform2, etc?

--


Gary



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 125
Default userform and variable

Don't think so, what are you trying to accomplish? Actually i'm not even sure
of the question, are you just wanting to change the name of the userform? or
set the name to a variable?

"Gary Keramidas" wrote:

anyway to set a userform name to a variable i can use with <variable name
instead of with userform1, with userform2, etc?

--


Gary




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,726
Default userform and variable

Is this the sort of thing you had in mind


Dim oUserForm As Object
On Error GoTo err
Set oUserForm = UserForms.Add("Userform1")
'...

With oUserform
.Show


--
---
HTH

Bob

(change the xxxx to gmail if mailing direct)
"John Bundy" wrote in message
...
Don't think so, what are you trying to accomplish? Actually i'm not even
sure
of the question, are you just wanting to change the name of the userform?
or
set the name to a variable?

"Gary Keramidas" wrote:

anyway to set a userform name to a variable i can use with <variable
name
instead of with userform1, with userform2, etc?

--


Gary






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 274
Default userform and variable

Hi Bob,

What is UserForms? I can't find it in the documentation. From your code
fragment it looks like a collection - but I created a spreadsheet with
2 userforms and when I type "?UserForms.Count" in the immediate window
I get 0 rather than 2. Is there any way to do something like the
following code fragment wants to do:

UserForms(myForm).Show

where myForm is a string variable? I know that you can do this sort of
thing for embedded active X controls via the Shapes collection.

Just curious - I can't imagine where I would need it in my code.

-John Coleman

Bob Phillips wrote:
Is this the sort of thing you had in mind


Dim oUserForm As Object
On Error GoTo err
Set oUserForm = UserForms.Add("Userform1")
'...

With oUserform
.Show


--
---
HTH

Bob

(change the xxxx to gmail if mailing direct)
"John Bundy" wrote in message
...
Don't think so, what are you trying to accomplish? Actually i'm not even
sure
of the question, are you just wanting to change the name of the userform?
or
set the name to a variable?

"Gary Keramidas" wrote:

anyway to set a userform name to a variable i can use with <variable
name
instead of with userform1, with userform2, etc?

--


Gary





  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,117
Default userform and variable

gary - i'd be interested in the answer to this, too, because when i
change the name of a userform to something like frmGenerate, i can't
get the initialization to run..........
but i didn't think of declaring it as a variable in my global
declarations module.........
susan

Gary Keramidas wrote:
anyway to set a userform name to a variable i can use with <variable name
instead of with userform1, with userform2, etc?

--


Gary




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default userform and variable

bob:

i was looking to use a variable to create the userform name. so instead of with
userform1, with userform2, i could use:
with userform(i)
..
..
end with
or
uform = userform1
then use the variable to manipulate the form ( i know this won't work, but)
with uform
..
..
end with

i've used me.controls("textbox" & i) and am wondering if there is a way to do
this with the form itself.

Gary


"Bob Phillips" wrote in message
...
Is this the sort of thing you had in mind


Dim oUserForm As Object
On Error GoTo err
Set oUserForm = UserForms.Add("Userform1")
'...

With oUserform
.Show


--
---
HTH

Bob

(change the xxxx to gmail if mailing direct)
"John Bundy" wrote in message
...
Don't think so, what are you trying to accomplish? Actually i'm not even sure
of the question, are you just wanting to change the name of the userform? or
set the name to a variable?

"Gary Keramidas" wrote:

anyway to set a userform name to a variable i can use with <variable name
instead of with userform1, with userform2, etc?

--


Gary








  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default userform and variable

thanks for the link, tom. looks like this is what i wanted

uform = "Userform1"
With VBA.UserForms.Add(uForm)
.Show
.Top = 100
End With

--


Gary


"Tom Ogilvy" wrote in message
...
Userforms is the collection of loaded userforms. Since you don't have any
loaded, it correctly reports zero.

Here is a bit more detail:

http://support.microsoft.com/kb/213574/en-us
XL2000: How to Display a UserForm Whose Name Is in a Variable

http://support.microsoft.com/kb/207714/en-us
XL2000: Run-Time Errors Using UserForms Collection

Then you will see the inspiration for Bob's code.

--
Regards,
Tom Ogilvy






"John Coleman" wrote:

Hi Bob,

What is UserForms? I can't find it in the documentation. From your code
fragment it looks like a collection - but I created a spreadsheet with
2 userforms and when I type "?UserForms.Count" in the immediate window
I get 0 rather than 2. Is there any way to do something like the
following code fragment wants to do:

UserForms(myForm).Show

where myForm is a string variable? I know that you can do this sort of
thing for embedded active X controls via the Shapes collection.

Just curious - I can't imagine where I would need it in my code.

-John Coleman

Bob Phillips wrote:
Is this the sort of thing you had in mind


Dim oUserForm As Object
On Error GoTo err
Set oUserForm = UserForms.Add("Userform1")
'...

With oUserform
.Show


--
---
HTH

Bob

(change the xxxx to gmail if mailing direct)
"John Bundy" wrote in message
...
Don't think so, what are you trying to accomplish? Actually i'm not even
sure
of the question, are you just wanting to change the name of the userform?
or
set the name to a variable?

"Gary Keramidas" wrote:

anyway to set a userform name to a variable i can use with <variable
name
instead of with userform1, with userform2, etc?

--


Gary








  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default userform and variable

here's the problem I've run into using VBA.UserForms.Add(uForm).

i set uform = "UF2"
then
VBA.UserForms.Add(uForm).show

unload uf2 doesn't work. the form is still displayed.

--


Gary


"Tom Ogilvy" wrote in message
...
Userforms is the collection of loaded userforms. Since you don't have any
loaded, it correctly reports zero.

Here is a bit more detail:

http://support.microsoft.com/kb/213574/en-us
XL2000: How to Display a UserForm Whose Name Is in a Variable

http://support.microsoft.com/kb/207714/en-us
XL2000: Run-Time Errors Using UserForms Collection

Then you will see the inspiration for Bob's code.

--
Regards,
Tom Ogilvy






"John Coleman" wrote:

Hi Bob,

What is UserForms? I can't find it in the documentation. From your code
fragment it looks like a collection - but I created a spreadsheet with
2 userforms and when I type "?UserForms.Count" in the immediate window
I get 0 rather than 2. Is there any way to do something like the
following code fragment wants to do:

UserForms(myForm).Show

where myForm is a string variable? I know that you can do this sort of
thing for embedded active X controls via the Shapes collection.

Just curious - I can't imagine where I would need it in my code.

-John Coleman

Bob Phillips wrote:
Is this the sort of thing you had in mind


Dim oUserForm As Object
On Error GoTo err
Set oUserForm = UserForms.Add("Userform1")
'...

With oUserform
.Show


--
---
HTH

Bob

(change the xxxx to gmail if mailing direct)
"John Bundy" wrote in message
...
Don't think so, what are you trying to accomplish? Actually i'm not even
sure
of the question, are you just wanting to change the name of the userform?
or
set the name to a variable?

"Gary Keramidas" wrote:

anyway to set a userform name to a variable i can use with <variable
name
instead of with userform1, with userform2, etc?

--


Gary








  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,726
Default userform and variable

You unload it from within the form, not the other code.

--
---
HTH

Bob

(change the xxxx to gmail if mailing direct)
"Gary Keramidas" <GKeramidasATmsn.com wrote in message
...
here's the problem I've run into using VBA.UserForms.Add(uForm).

i set uform = "UF2"
then
VBA.UserForms.Add(uForm).show

unload uf2 doesn't work. the form is still displayed.

--


Gary


"Tom Ogilvy" wrote in message
...
Userforms is the collection of loaded userforms. Since you don't have
any
loaded, it correctly reports zero.

Here is a bit more detail:

http://support.microsoft.com/kb/213574/en-us
XL2000: How to Display a UserForm Whose Name Is in a Variable

http://support.microsoft.com/kb/207714/en-us
XL2000: Run-Time Errors Using UserForms Collection

Then you will see the inspiration for Bob's code.

--
Regards,
Tom Ogilvy






"John Coleman" wrote:

Hi Bob,

What is UserForms? I can't find it in the documentation. From your code
fragment it looks like a collection - but I created a spreadsheet with
2 userforms and when I type "?UserForms.Count" in the immediate window
I get 0 rather than 2. Is there any way to do something like the
following code fragment wants to do:

UserForms(myForm).Show

where myForm is a string variable? I know that you can do this sort of
thing for embedded active X controls via the Shapes collection.

Just curious - I can't imagine where I would need it in my code.

-John Coleman

Bob Phillips wrote:
Is this the sort of thing you had in mind


Dim oUserForm As Object
On Error GoTo err
Set oUserForm = UserForms.Add("Userform1")
'...

With oUserform
.Show


--
---
HTH

Bob

(change the xxxx to gmail if mailing direct)
"John Bundy" wrote in message
...
Don't think so, what are you trying to accomplish? Actually i'm not
even
sure
of the question, are you just wanting to change the name of the
userform?
or
set the name to a variable?

"Gary Keramidas" wrote:

anyway to set a userform name to a variable i can use with
<variable
name
instead of with userform1, with userform2, etc?

--


Gary










  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default userform and variable

If you have

Private Sub frmGenerate_Initialize()

then that is the problem. No matter the userform name, it should always be

Private Sub Userform_Initialize()


--
Regards,
Tom Ogilvy


"Susan" wrote in message
ps.com...
gary - i'd be interested in the answer to this, too, because when i
change the name of a userform to something like frmGenerate, i can't
get the initialization to run..........
but i didn't think of declaring it as a variable in my global
declarations module.........
susan

Gary Keramidas wrote:
anyway to set a userform name to a variable i can use with <variable
name
instead of with userform1, with userform2, etc?

--


Gary






  #11   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,117
Default userform and variable

tom - yes, that's what i have to do. but if you have a macro where
you're calling various userforms from the main macro, it would be nice
to be able to differentiate them more easily, even tho i know the
initialize sub is directly connected to that specific userform......
when i've got five different userform windows open it gets a little
confusing LOL
susan

Tom Ogilvy wrote:
If you have

Private Sub frmGenerate_Initialize()

then that is the problem. No matter the userform name, it should always be

Private Sub Userform_Initialize()


--
Regards,
Tom Ogilvy


"Susan" wrote in message
ps.com...
gary - i'd be interested in the answer to this, too, because when i
change the name of a userform to something like frmGenerate, i can't
get the initialization to run..........
but i didn't think of declaring it as a variable in my global
declarations module.........
susan

Gary Keramidas wrote:
anyway to set a userform name to a variable i can use with <variable
name
instead of with userform1, with userform2, etc?

--


Gary



  #12   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,726
Default userform and variable

then you seem to be asking the same question as Gary, so the answer is the
same

--
---
HTH

Bob

(change the xxxx to gmail if mailing direct)
"Susan" wrote in message
ups.com...
tom - yes, that's what i have to do. but if you have a macro where
you're calling various userforms from the main macro, it would be nice
to be able to differentiate them more easily, even tho i know the
initialize sub is directly connected to that specific userform......
when i've got five different userform windows open it gets a little
confusing LOL
susan

Tom Ogilvy wrote:
If you have

Private Sub frmGenerate_Initialize()

then that is the problem. No matter the userform name, it should always
be

Private Sub Userform_Initialize()


--
Regards,
Tom Ogilvy


"Susan" wrote in message
ps.com...
gary - i'd be interested in the answer to this, too, because when i
change the name of a userform to something like frmGenerate, i can't
get the initialization to run..........
but i didn't think of declaring it as a variable in my global
declarations module.........
susan

Gary Keramidas wrote:
anyway to set a userform name to a variable i can use with <variable
name
instead of with userform1, with userform2, etc?

--


Gary




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
Userform and variable Jeff Excel Discussion (Misc queries) 1 March 16th 07 03:14 PM
preserving variable from userform Gary Keramidas Excel Programming 3 October 28th 06 04:44 AM
VBA Variable as userform [email protected] Excel Programming 3 April 13th 06 08:32 PM
Variable ComboBox on Userform DHallam Excel Programming 2 July 19th 05 12:20 PM
Passing a value to a variable from Userform Neal Steiner Excel Programming 1 July 18th 03 09:12 PM


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