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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Select worksheet on userform exit - error 13 'Type Mismatch'

Status
Not open for further replies.

davedave24

Programmer
Aug 26, 2010
113
GB
I'm trying to select a specific worksheet upon exit of the userform, but it's generating the error 'Type Mismatch'.

The name of the form is loaded into a textbox named textQuoteNo. This is populated from the actual sheet the userform is loaded from.

As the form fetches data for comboboxes from another sheet ("Data"), when I exit the userform, it dumps me on the Data worksheet.

Code:
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
    Sheets(textQuoteNo).Select
End Sub

I've tried combinations of .Activate, ThisWorkbook etc. but it still gives the error.

The code works fine if I specify a sheet name, ie
Code:
Sheets("Quotes").Select
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top