recalling named ranges as must fill cell

A

alex.ferrazza

on my workbook I have some ranges that must be filled in prior to
saving the file:

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, _
Cancel As Boolean)
Dim checkCells As Range
Dim cell As Range
Set checkCells = Sheets("Sheet1").Range("A1, B2, C3")
For Each cell In checkCells
Cancel = Cancel Or IsEmpty(cell)
Next cell
If Cancel Then
MsgBox "Cell(s) " & Replace(checkCells.Address( _
False, False), ",", ", ") & _
" must be filled in prior to saving."
End If
End Sub

What I want to acieve is this A1 cosrresponds to Name and B2
corresponds to Address I would like the user to have a flag that sais
you must fill in Name, Address etc and the cells are a different
colour on the spreadsheet.

id it possible?

thanks

Alex
 
B

Bob Phillips

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, _
Cancel As Boolean)
Dim checkCells As Range
Dim cell As Range
Dim msg As String

msg = "Cell(s) "
Set checkCells = Sheets("Sheet1").Range("A1, B2, C3")
For Each cell In checkCells
If IsEmpty(cell.Value) Then
msg = msg & cell.Address(False, False) & vbNewLine
Cancel = True
End If
Next cell
If Cancel Then
MsgBox msg & " must be filled in prior to saving."
End If
End Sub


--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my addy)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top