First, you "snip" appears to include the start of another sub, then the Workbook_BeforeClose macro. Make sure you don't have that error in your workbook, too!
Macros in the ThisWorkbook module are global. Anything you construct in there must include full addressing to the correct sheet. Your "Range" command has no parent sheet indicated, so the macro doesn't know where to apply that range command.
Private Sub Workbook_BeforeClose(Cancel As Boolean)
If MsgBox("Closing this form will clear all data and assign a new PO number. Please confirm.", vbYesNo, "Confirm") = vbNo Then
Cancel = True
Exit Sub
End If
ActiveWorkbook.Unprotect ("hidden")
With Sheets("Sheet1") 'correct this sheet name
.Range("H3").Value = .Range("H3").Value + 1
.Range("A10:H15,E5:H5,B17:H17,A20:H20,A24:G38").ClearContents
End With
ActiveWorkbook.Protect ("hidden")
Cancel = True
ActiveWorkbook.Close True
End Sub
Bookmarks