Thread: Excel VBA help
View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.misc
vmc vmc is offline
external usenet poster
 
Posts: 1
Default Excel VBA help

I am needing some help with this vba code. What I am trying to do is first
verify if cell A4 is not empty, if it is not empty then I need it to make
sure there is data in the other columns before anyone can save. This is what
I got so far but it is saving and not bring the popup message that data is
missing.


Private Sub Workbook_BeforeSave(ByVal SaveAsUi As Boolean, Cancel As Boolean)

If IsEmpty(A4) = False Then 'make sure that A4 is not empty prior to running
the below if


If Worksheets("User's Sheet").Range("B4").Value = "" Then
msg = "Program Short Name must be filled in before saving."
Cancel = True
End If

'and

If Worksheets("User's Sheet").Range("F4").Value = "" Then
msg = "Gender must be filled in before saving."
Cancel = True
End If

'and

If Worksheets("User's Sheet").Range("G4").Value = "" Then
msg = "Color Name must be filled in before saving."
Cancel = True
End If

'and


If Worksheets("User's Sheet").Range("H4").Value = "" Then
msg = "Size must be filled in before saving."
Cancel = True
End If

'and

If Cancel Then
MsgBox msg
End If




End If
End Sub