ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How do I make a value required in a cell in Excel? ex: Name, Last. (https://www.excelbanter.com/excel-programming/312706-how-do-i-make-value-required-cell-excel-ex-name-last.html)

Pilar

How do I make a value required in a cell in Excel? ex: Name, Last.
 
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!

Paul B[_8_]

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!




Tom Ogilvy

How do I make a value required in a cell in Excel? ex: Name, Last.
 
See Events at Chip Pearson's site

http://www.cpearson.com/excel/events.htm

look at the BeforePrint, BeforeSave and BeforeClose events.

You also might want to look at the selectionchange and change events.

--
Regards,
Tom Ogilvy

"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!





All times are GMT +1. The time now is 09:22 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com