mandatory cells only if another cell is filled

  • Thread starter Thread starter Guest
  • Start date Start date
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.
 
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
 
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
 
Back
Top