ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Conditional Formatting based on data in adjacent cell & restrict save without required data (https://www.excelbanter.com/excel-programming/396482-conditional-formatting-based-data-adjacent-cell-restrict-save-without-required-data.html)

bjohnson

Conditional Formatting based on data in adjacent cell & restrict save without required data
 
In the range of (B23:L147). Col B has header "W/P/L/F", Col F has
header "Customer" and Col L has header "Amount". If the user enters
any data in any row in the range in column F, without entering data
into the adjacent columns B and L, I want the cells n that same row in
Col's B and L to highlight red. I also want to make sure they cannot
"save" the file without filling in those cells. Can anyone help me?


[email protected]

Conditional Formatting based on data in adjacent cell & restrict save without required data
 
On Aug 28, 8:18 pm, bjohnson wrote:
In the range of (B23:L147). Col B has header "W/P/L/F", Col F has
header "Customer" and Col L has header "Amount". If the user enters
any data in any row in the range in column F, without entering data
into the adjacent columns B and L, I want the cells n that same row in
Col's B and L to highlight red. I also want to make sure they cannot
"save" the file without filling in those cells. Can anyone help me?


Format Conditional Formatting. In B23 and L23 and drag down: Formula
is:=AND(F23<"",L23="",B23="") and add desired formatting.
To stop saving, add formula in M23 (or anywhere)
=IF(AND(F23<"",B23="",L23=""),1,"") and drag down and then in
Workbook BeforeSave event,

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)

If WorksheetFunction.Sum(Sheet1.Range("M23:M26")) 0 Then
MsgBox "Please fill in gaps"
Cancel = True
End If

End Sub



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

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