ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to Get Past the User Form? (https://www.excelbanter.com/excel-programming/319589-how-get-past-user-form.html)

JimFor

How to Get Past the User Form?
 
Hi,

I'm writing a program which uses user input data. I have written the user form
part and was experimenting with the rest of the program. However, it looks
like the program stops after I close the user form. Here is a little part of
the program.
------------------------------------------------------------------------
Private Sub CancelButton_Click()
Unload UserForm1
End Sub
--------------------------------------------------------------------------
-------------
Private Sub OKButton_Click()
Sheet1.Cells(1, 10) = FirstDate
Sheet1.Cells(1, 11) = SecondDate
Sheet1.Cells(1, 12) = NoToFill
'Replace 0 values in Trade Date Field with values in Post Date field
For Kount = 2 To NoToFill
Input1 = Sheet2.Cells(Kount, 1)
Input2 = Sheet2.Cells(Kount, 2)
If Input2 = 0 Then
Sheet2.Cells(Kount, 2) = Input1
Else
Sheet2.Cells(Kount, 1) = Input2
End If
Next Kount
Unload UserForm1
End Sub
-----------------------------------------------------------
Sub MySub()
Sheet3.Cells(5, 5) = 5
End Sub
-----------------------------------

Since nothing shows up on sheet3 I assume the program never gets to Sub
MySub(). So far, no matter what I write after I close the user form it does
not process. Can anyone tell me how to get past the user form part? I thought
the program would do the next sub after the user form was unloaded.

Thanks

Chip Pearson

How to Get Past the User Form?
 
Try something like

Sub Test()
Userform1.Show
MySub
End Sub


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com




"JimFor" wrote in message
...
Hi,

I'm writing a program which uses user input data. I have
written the user form
part and was experimenting with the rest of the program.
However, it looks
like the program stops after I close the user form. Here is a
little part of
the program.
------------------------------------------------------------------------
Private Sub CancelButton_Click()
Unload UserForm1
End Sub
--------------------------------------------------------------------------
-------------
Private Sub OKButton_Click()
Sheet1.Cells(1, 10) = FirstDate
Sheet1.Cells(1, 11) = SecondDate
Sheet1.Cells(1, 12) = NoToFill
'Replace 0 values in Trade Date Field with values in Post Date
field
For Kount = 2 To NoToFill
Input1 = Sheet2.Cells(Kount, 1)
Input2 = Sheet2.Cells(Kount, 2)
If Input2 = 0 Then
Sheet2.Cells(Kount, 2) = Input1
Else
Sheet2.Cells(Kount, 1) = Input2
End If
Next Kount
Unload UserForm1
End Sub
-----------------------------------------------------------
Sub MySub()
Sheet3.Cells(5, 5) = 5
End Sub
-----------------------------------

Since nothing shows up on sheet3 I assume the program never
gets to Sub
MySub(). So far, no matter what I write after I close the
user form it does
not process. Can anyone tell me how to get past the user form
part? I thought
the program would do the next sub after the user form was
unloaded.

Thanks




JimFor

How to Get Past the User Form?
 
OK. Will try it. Another thing which seems to work is to call My Sub right
after the "Unload UserForm1" line Perhaps when using the approach I used one
must run the main part of the program before ending the user form part? I
don't know. Still learning. But I know I know a lot more than I did when I
first started.

Thanks


All times are GMT +1. The time now is 05:28 PM.

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