Validation

  • Thread starter Thread starter Heath Higgins
  • Start date Start date
H

Heath Higgins

I would like to have a cell on a spreadsheet configured so if a user tries
to open the speadsheet without populating a specific cell the worksheet
would not save and a msgbox would pop and inform the user that the cell must
be populated. Not concerned at the moment of what data is populated as long
as is there is something in this cell. Any help would be appreciated.

Thanks!
 
Heath,

Trap the BeforeSave evenet like so

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

If Thisworkbook.Worksheets("Sheet1").Range("A1").Value = ""
Cancel = True
MsgBox "Cell A1 must be poulated before saving

End Sub

and maybe also make sure it is saved ebfore exitiing (optional)

Private Sub Workbook_BeforeClose(Cancel As Boolean)
If Me.Saved = False Then
MsgBox "Please save before closing."
Cancel = True
End If
End Sub

The code goes in the Thisworkbook code module.

--

HTH

RP
(remove nothere from the email address if mailing direct)
 
cool beans. will give it a try.

thanks!


Bob Phillips said:
Heath,

Trap the BeforeSave evenet like so

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

If Thisworkbook.Worksheets("Sheet1").Range("A1").Value = ""
Cancel = True
MsgBox "Cell A1 must be poulated before saving

End Sub

and maybe also make sure it is saved ebfore exitiing (optional)

Private Sub Workbook_BeforeClose(Cancel As Boolean)
If Me.Saved = False Then
MsgBox "Please save before closing."
Cancel = True
End If
End Sub

The code goes in the Thisworkbook code module.

--

HTH

RP
(remove nothere from the email address if mailing direct)
 
Back
Top