Making cells mandatory to fill in
You'll want to provide the worksheet name to check, too.
Option Explicit
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Dim cell As Range
For Each cell In Me.Worksheets("Sheet1").Range("d5,g5,j5,e7,m7,g10" )
If IsEmpty(cell.Value) Then
MsgBox "You must fill in cell " & cell.Address
Application.Goto cell
Cancel = True
Exit For
End If
Next cell
End Sub
wkmooreh wrote:
I need help, I am working on an excel expense report templete and want them
to fill in certain cells before they exit. When I copied the thread from
below I keep getting error messages. I dont know if I am putting valoues of
the cells i want filled out in the wrong place or not. This is what it looks
like: it says for each cell in range line is not right...
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Dim cell As Range
For Each cell In Range(d5, g5, j5, e7, m7, g10)
If IsEmpty(cell.Value) Then
MsgBox "You must fill in cell " & cell.Address
Application.Goto cell
Cancel = True
Exit For
End If
Next cell
End Sub
--
wkmooreh
"abfabrob" wrote:
I am creating an application form where I want users to fill certain cells in
before closing the document.
Does anyone have an idiots guide to doing this, cos I'm not great with excell.
ANY help welcome!!!
--
Dave Peterson
|