How do you make user form enter data, call another and then go away?

Caveman1964

Board Regular
Joined
Dec 14, 2017
Messages
127
Office Version
  1. 2016
Platform
  1. Windows
I have user forms and trying to get them to work one after another.
The issue is the first one is still active while second one shows up. The data entered but form still there.
I tried hide and unload but then my data went away.
Any help is appreciated. Here is current code from a NOVICE.

First Form
Private Sub Entercompnum_Click()
Sheets("Do Not Alter").Unprotect "1"
Sheets("Data Collection").Unprotect "1"
Sheets("Complaint Entry").Unprotect "1"


Sheets("Complaint Entry").Select
Range("E5").Select
If compnum.Value = "" Then
missingcompnum.Show
Exit Sub
End If


ActiveCell = compnum.Value
If IsNumeric(compnum) Then
mtch = Application.Match(Title, Worksheets("Data Collection").Columns(1), 0)
If IsError(mtch) Then mtch = Application.Match(CDbl(compnum), Worksheets("Data Collection").Columns(1), 0)
Else
mtch = Application.Match(Title, Worksheets("Data Collection").Columns(1), 0)
End If


If Not IsError(mtch) Then
duplicate1.Show

Worksheets("Complaint Entry").Range("E5").Value = vbNullString
Else
Worksheets("Complaint Entry").Range("E5").Value = compnum
End If
entdatecomprec.Show


End Sub

Second form
Private Sub entcomprecdatebutton_Click()
Sheets("Do Not Alter").Unprotect "1"
Sheets("Data Collection").Unprotect "1"
Sheets("Complaint Entry").Unprotect "1"




Sheets("Complaint Entry").Select
Range("E6").Select
If entcompdatetextbox.Value = "" Then
missingcompnum.Show
Exit Sub
End If


ActiveCell = entcompdatetextbox.Value
Unload Me
End Sub
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
.
Code:
  Unload Me       '<-- unloads present form
  UserForm2.Show  '<-- loads the second form
'edit names as required.
 
Upvote 0
Of course that worked!
Thank you again for your help!
I am learning but my brain is starting to hurt. :laugh:
 
Upvote 0
.
Continue programming and you'll end up like me ... bald.

Glad to help.
 
Upvote 0

Forum statistics

Threads
1,223,888
Messages
6,175,219
Members
452,620
Latest member
dsubash

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top