So im very new to the use of VBA in Microsoft Excel. I have created worksheets for work and mostly through help from online sources have gotten a working code I use.
The thing is, I want to merge multiple Workbooks together and I need to get my code so it effects only 1 Sheet of a workbook. Otherwise all my sheets conflict and stuff.
I have a Excel document with 2 Sheets
Sheet1 Venison
Sheet2 Drops
Here is the Code for the Workbook.
Private Sub Workbook_BeforeClose(Cancel As Boolean)
If ([AC2] = "") Or ([AC3] = "") Or ([D4] = "") Or ([R4] = "") Or ([D5] = "") Or ([N5] = "") Or ([V5] = "") Or ([D6] = "") Or ([M6] = "") Or ([S6] = "") Or _
([X6] = "") Then
MsgBox "Please make sure all Contact Information is filled in:", vbExclamation, "You are missing required information!"
Cancel = True
End If
'Instructions By: [AC2]
'Deer #: [AC3]
'Name: [D4]
'License #: [R4]
'Phone #: [D5]
'Alt. Ph. #: [N5]
'Email: [V5]
'Address: [D6]
'City: [M6]
'State: [S6]
'Zip: [X6]
'Animal: [D7]
End Sub
Private Sub Workbook_BeforePrint(Cancel As Boolean)
If ([AC2] = "") Or ([AC3] = "") Or ([D4] = "") Or ([R4] = "") Or ([D5] = "") Or ([N5] = "") Or ([V5] = "") Or ([D6] = "") Or ([M6] = "") Or ([S6] = "") Or _
([X6] = "") Then
MsgBox "Please make sure all Contact Information is filled in:", vbExclamation, "You are missing required information!"
Cancel = True
End If
End Sub
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
If ([AC2] = "") Or ([AC3] = "") Or ([D4] = "") Or ([R4] = "") Or ([D5] = "") Or ([N5] = "") Or ([V5] = "") Or ([D6] = "") Or ([M6] = "") Or ([S6] = "") Or _
([X6] = "") Then
MsgBox "Please make sure all Contact Information is filled in:", vbExclamation, "You are missing required information!"
Cancel = True
End If
End Sub
I want this Code to only effect Sheet 1, Becuase I want to merge another document that has this code with different positions for its Sheet.
Long Story Short.
3 Documents - Sheet1 Venison, Sheet1 Elk, Sheet1Bear. All different workbooks that im merging and need all their code sets to work.
Bookmarks