PDA

View Full Version : Exit sub issues



lwagner00
01-16-2009, 01:40 PM
I have this formula but cannot make the exit sub function work when I insert this command. I want the box to close when okay is selected to eliminate the possibility of duplicate entries

HELP


Private Sub Okay_Click()
Columns("A:E").Select
ActiveSheet.Unprotect
Range("B2").Select
Do
If IsEmpty(ActiveCell) = False Then
ActiveCell.Offset(1, 0).Select
End If

Loop Until IsEmpty(ActiveCell) = True
ActiveCell.Value = Ministry.Value
ActiveCell.Offset(0, 1) = FiscalYear.Value
ActiveCell.Offset(0, 2) = TypeOfDoc.Value
ActiveCell.Offset(0, 3) = DocPpdBy.Value
ActiveCell.Offset(0, 4) = EnteredBy.Value
Columns("A:E").Select
ActiveSheet.Unprotect
ActiveSheet.Calculate


With Worksheets("entry")
If Not .AutoFilterMode Then
.Range("A1").AutoFilter
End If
.EnableAutoFilter = True
.Protect , _
Contents:=True, UserInterfaceOnly:=True

End With

'ActiveSheet.Protect
End Sub

Bob Phillips
01-16-2009, 01:48 PM
What box are you referring to? Is it a userform or something else?

CreganTur
01-16-2009, 02:12 PM
Welcome to the forum- it's always good to see new members.

If your click event refers to a UserForm, then you can close the forum using this code:
Me.Unload
Me refers to the current, active form- the form that the code is behind. Unload closes the UserForm and clears the memory.

If this isn't the answer you're looking for, then please provide some more detail.

Also, when you post code please wrap your code in VBA tags (click the green VBA button). This will format the code according to VBIDE and make it easier to read.

If your issue is resolved, please mark the thread as solved by clicking on Thread Tools at the top of this window, and select Mark As Solved- it will help keep the forum clean.

HTH:thumb

lwagner00
01-16-2009, 02:51 PM
I have tried the Me.Upload and it errors out. The macro allows the user to enter in data via a form with drop down choices. Once completed they can select the okay button on the user form to enter the data. At this point I would like the box/user form to close.

Please advise

lucas
01-16-2009, 04:27 PM
unload me

just above End Sub