mandatory cells only if another cell is filled

G

Guest

I have checked other postings regarding VBA codes for making cells mandatory
if another cell is filled. I have tried the different statements in various
postings but they did not work for me. I need to have C38 mandatory only if
A38 is filled. I also need this condition up to row 46. If cells in column
A are filled then the corresponding rows in column C have to be filled,
otherwise, the file cannot be saved.

Thanks.
 
G

Guest

in the thisworkbook module:

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
set rng = Worksheets("Sheet1").Range("A38:A46")
for each cell in rng
if not isempty(cell) and isempty(cell.offset(0,2)) then
Application.Goto cell.offset(0,2)
Cancel = True
msgbox "Please fill in cells in column C for " & _
vbNewLine & "corresponding filled in cells in column A in rows "
& vbNewLine & "38 to 46. Save is cancelled!"
end if
Next
End Sub
 

abb

Joined
Oct 2, 2017
Messages
2
Reaction score
0
This worked perfectly except I need it to continue to give the error until all columns b-h are completely filled out, also columns d-h are drop downs
 

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