Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Return to Sheet after displaying User Form 1

Status
Not open for further replies.

artsandcraftshome

Technical User
Mar 24, 2003
13
US
I would like to return to my sheet after displaying a user form, but it just returns me to the VBA page (after flashing the sheet but not retaining it). Any ideas why this is happening?
Thanks for any help you might offer..I'm stumped. John
Here's my code:

Sub eMD()
Sheets("eMD").Select
AVGDIM = InputBox("Enter the average Field Size on skin (cm)")
Range("C7").Select
Selection.FormulaR1C1 = AVGDIM

PRESCD = InputBox("Enter the Prescription Depth(cm)")
Range("C8").Select
Selection.FormulaR1C1 = PRESCD

'Set the variable PDEPTH to the prescription field depth
PDEPTH = Range("I7").Value
SKINFS = Range("I8").Value
'Display the PDD table sheet
Sheets("PDD TABLES").Select
'Select the row for the prescription depth and the column where this FS PDD starts
Cells(SKINFS, PDEPTH).Select
'Display a form that will retrieve the value of PDD from the PDD table
frmeMD.Show
'Set the sheet back to the eMD sheet
Sheets("eMD").Select
Range("C10").Select

End Sub

AND HERE'S THE CODE FOR THE USER FORM:
Private Sub CommandButton1_Click()

Dim SelRangeMD As Range
Dim AddrMD As String
'Get the address from the RefEdit control
AddrMD = RefEdit1.Value

'Set the SelRange object to the range specified in the RefEdit control
Set SelRangeMD = Range(AddrMD)

MDCHOICE = SelRangeMD.Value

ThisWorkbook.Worksheets("eMD").Range("C10").Value = CInt(MDCHOICE)

'unload the UserForm
Unload Me

End Sub


Private Sub UserForm_Click()

End Sub
 
That's because you are running it from the VBA editor. Run it from the worksheet and you will return to the worksheet. Either use Alt-F8 or assign a macro shortcut (or drop a button on the sheet and assign a macro to the button.)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top