View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Paul B[_8_] Paul B[_8_] is offline
external usenet poster
 
Posts: 20
Default How do I make a value required in a cell in Excel? ex: Name, Last.

Pilar, here is one way, change the range to the cells you want

Private Sub Workbook_BeforePrint(Cancel As Boolean)
Dim test_rng As Range
Dim ret_str As String
Dim cell As Range

'change to your range
Set test_rng = ActiveSheet.Range("A1:A5,B1")

For Each cell In test_rng
If cell.Value = "" Then
If ret_str = "" Then
ret_str = cell.Address
Else
ret_str = ret_str & " and " & cell.Address
End If
End If
Next
If ret_str < "" Then
MsgBox "There is information missing in cell(s): " & ret_str
Cancel = True
Else

End If

End Sub

--
Paul B
Always backup your data before trying something new
Please post any response to the newsgroups so others can benefit from it
Feedback on answers is always appreciated!
Using Excel 2000 & 2003
** remove news from my email address to reply by email **

"Pilar" wrote in message
...
Users are downloading a spreadsheet where they should be filling in
important
values to HR such as Name, Last Name, Social Security, etc.
Besides there are other values such as Standard number of hours they work
(20, 37.5, 40, etc) that are being used to calculate overtime, benefits,
etc.
so they must be filled in.

Is there a way to make these fields required before printing/saving the
spreadsheet?
Thank you!