ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Is it possible to call a UserForm multiple times? (https://www.excelbanter.com/excel-programming/287749-possible-call-userform-multiple-times.html)

Doug[_9_]

Is it possible to call a UserForm multiple times?
 
I have some simple code, which compares cells in two adjacent columns. If any two cells in one row are not equal, it displays a UserForm. When I call the UserForm, I use a vbModeless command, so that calling this UserForm does not stop the rest of the macro. Example:

UserForm2.Show vbModeless

Since I have a lot of numbers changing, I need to have the userform pop up many times, each time the two cells in any row are not equal. Using the above line of code, can the UserForm be called and appear on the screen multiple times? Thank you.

KJTFS[_23_]

Is it possible to call a UserForm multiple times?
 
Yes but you have to create them as new objects like this.

Dim xlFrm As frmNew '' or whatever you named it.
Set xlFrm = New frmNew1

xlFrm.Caption = "TEST"
xlFrm.Show vbmodaless


That will let you create a bunch of them but closing them is a little
harder you will need some type of unique identifier on all of them then
loop thru all forms to find the one that needs to be closed and then
hide or unload it.

Something like

For i = 0 to UserForms.count -1

if userforms(i)."what ever you use to hold ID" = "what you are looking
for.."
userforms(i).hide
endif


next i

Keith
www.kjtfs.com


---
Message posted from http://www.ExcelForum.com/


Bob Phillips[_6_]

Is it possible to call a UserForm multiple times?
 
Doug,

No you won't be able to. You can issue the command multiple times, but as it
is already in memory, it will reuse that same userform.

--

HTH

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

"Doug" wrote in message
...
I have some simple code, which compares cells in two adjacent columns. If

any two cells in one row are not equal, it displays a UserForm. When I call
the UserForm, I use a vbModeless command, so that calling this UserForm does
not stop the rest of the macro. Example:

UserForm2.Show vbModeless

Since I have a lot of numbers changing, I need to have the userform pop up

many times, each time the two cells in any row are not equal. Using the
above line of code, can the UserForm be called and appear on the screen
multiple times? Thank you.



Doug[_9_]

Is it possible to call a UserForm multiple times?
 
KJTFS

Thank you. The code you posted worked like a charm. And if I put a Command Button on the Form, and put in the following code for hte button

Private Sub CommandButton1_Click(
Me.Hid
End Su

It will only close out that UserForm, not all the UserForms.

KJTFS[_24_]

Is it possible to call a UserForm multiple times?
 
Welcome, and thats good.

Keith
www.kjtfs.com

~× wrote:
*KJTFS,

Thank you. The code you posted worked like a charm. And if I put
Command Button on the Form, and put in the following code for ht
button:

Private Sub CommandButton1_Click()
Me.Hide
End Sub

It will only close out that UserForm, not all the UserForms.


--
Message posted from http://www.ExcelForum.com



All times are GMT +1. The time now is 01:19 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com