-
Solved: type mismatch on open
I am opening a workbook from another and get an error of type mismatch after it has run the code in the second workbook on opening. The code work great if opened manually. The error occurs at end sub.
Here is the code:
[VBA]
Private Sub Workbook_Open()
If Evaluate("=isblank(name)") = False Then GoTo Non
nam = InputBox(Prompt:="Please enter your name", Title:="NEW WEEK")
If nam = "" Then Exit Sub
Range("totals!name").Value = nam
hos = InputBox(Prompt:="Please enter your number", Title:="number")
If hos = "" Then Exit Sub
Range("totals!hosnum").Value = "NUMBER"
Range("totals!hosnum1").Value = hos
' retreive the file name from diet
workfil = Workbooks("diet.xlsm").Worksheets("Sheet1").Range("shfname")
' save the file
Application.DisplayAlerts = False
SaveAs Filename:=workfil
Application.DisplayAlerts = True
Non:
End Sub
[/VBA]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules