Highlighting blank cells based on another value, but columns aren't always the same

nfunkhouser

New Member
Joined
Mar 25, 2025
Messages
5
Office Version
  1. 365
Platform
  1. Windows
I have a spreadsheet where I'm looking to highlight the Network ID if they put YES in the Network Requested field - the issue I'm having is that the people who submit these to us like to move things around, so I don't always know if the Network ID will be in the same column - sometimes it's in I, sometimes H, sometimes they move it to the end and it's in column BA. It's a pain, but sending them back isn't an option. Is there a way to do this using either VBA or conditional formatting, when I don't know what the column letters will be?

What it looks like:
1742934026374.png



What I'd like it to do - highlight the blank Network ID since they put YES in Network Requested but didn't provide a Network ID
1742934062782.png
 
The real solution to this is to protect the sheet so they can't move anything around.

You didn't give us any context for what your sheet looks like. I don't know what rows and columns you are using. I'll assume the first column is A, and headers are in row 1 and data starts in row 2.

The Applies To range for this rule will be $A$2:$Z$99 where $Z$99 to the last possible cell where you could have data. Change to suit:
Excel Formula:
=AND(INDEX(A:A,1)="Network ID",INDEX($A$2:$Z$99,ROW(A2)-1,MATCH("Network Requested",$A$1:$Z$1,0))="Yes")
I have not tested this because I did not take the time to type in the data from scratch from a picture, but you can try it and let me know how it works. Consider pasting in data directly from your post. The best solution is to use the XL2BB add-in which allows you paste in something pretty close to a spreadsheet.
 
Upvote 0
Welcome to the MrExcel board!

Looks like formal Excel table so try Conditional Formatting like this in the Network ID column (don't forget to check the table name and column label)

nfunkhouser.xlsm
BCDEFGH
4SomethingNetwork RequestedOtherNetwork IDPhoneMore 1More 2
5Yes3319
6Yes8901
7No
8Yes
9No
10Yes899353
11No
Sheet1
Cells with Conditional Formatting
CellConditionCell FormatStop If True
E5:E11Expression=AND(E5="",INDIRECT("Table1[@Network Requested]")="Yes")textNO


Now if I drag some columns to different places ..

nfunkhouser.xlsm
BCDEFGH
4SomethingNetwork IDOtherMore 2PhoneNetwork RequestedMore 1
53319Yes
68901Yes
7No
8Yes
9No
10899353Yes
11No
Sheet1
Cells with Conditional Formatting
CellConditionCell FormatStop If True
C5:C11Expression=AND(C5="",INDIRECT("Table1[@Network Requested]")="Yes")textNO


Is that the sort of thing you are after?
 
Upvote 0
Since the size is data is large and the column of ID is not fixed, the entire data range is to be conditionally formatted. This may slow down excel. It is better to go for Macro. Is it ok .
 
Upvote 0
Since the size is data is large and the column of ID is not fixed, the entire data range is to be conditionally formatted. This may slow down excel. It is better to go for Macro. Is it ok .
Yes, a macro would be fine - I just wasn't sure which was best for this situation.
 
Upvote 0
Welcome to the MrExcel board!

Looks like formal Excel table so try Conditional Formatting like this in the Network ID column (don't forget to check the table name and column label)

nfunkhouser.xlsm
BCDEFGH
4SomethingNetwork RequestedOtherNetwork IDPhoneMore 1More 2
5Yes3319
6Yes8901
7No
8Yes
9No
10Yes899353
11No
Sheet1
Cells with Conditional Formatting
CellConditionCell FormatStop If True
E5:E11Expression=AND(E5="",INDIRECT("Table1[@Network Requested]")="Yes")textNO


Now if I drag some columns to different places ..

nfunkhouser.xlsm
BCDEFGH
4SomethingNetwork IDOtherMore 2PhoneNetwork RequestedMore 1
53319Yes
68901Yes
7No
8Yes
9No
10899353Yes
11No
Sheet1
Cells with Conditional Formatting
CellConditionCell FormatStop If True
C5:C11Expression=AND(C5="",INDIRECT("Table1[@Network Requested]")="Yes")textNO


Is that the sort of thing you are after?
If I'm understanding correctly, this would require us to alter the formula each time we get a spreadsheet back, is that right? Unfortunately, it needs to be friendly enough to use for people who aren't familiar with higher end excel formatting - which is why I'm trying to create something to help automate it. (:
 
Upvote 0
Calender formation for Excel 365 version.xlsm
ABCDEFGHIJKLMN
1AAABBBCCCNetwork RequestedEEEwwrrFFFGGNetwork IDZZJJJKKHN!
2saasBBBYes22
3saasNo44
4saasYes55
5saasNo
6saasYes
7saasYes66
8saasYes
9saasYes45
10saasYes
11saasYes
Sheet5

Data range assumed is up to column BZ, change as required in code.
VBA code.
VBA Code:
Sub HighlightID()
Dim Ip As Range, hdr As Range
Dim Lr&, T&, ClmNR&, ClmID, P$
Dim M

Lr = Range("A" & Rows.Count).End(xlUp).Row
Set Ip = Range("A2:BZ" & Lr)
Set hdr = Range("A1:BZ1")

ClmNR = WorksheetFunction.Match("Network Requested", hdr, 0)
ClmID = WorksheetFunction.Match("Network ID", hdr, 0)
P = "transpose(If((" & Ip.Columns(ClmNR).Address & "=""Yes"")*(" & _
    Ip.Columns(ClmID).Address & "=""""),Row(" & Ip.Columns(ClmNR).Address & "),False))"
M = Filter(Evaluate(P), False, False)
For T = 0 To UBound(M)
Cells(M(T), ClmID).Interior.Color = 65535
Next T

End Sub
 
Upvote 0
Solution
Calender formation for Excel 365 version.xlsm
ABCDEFGHIJKLMN
1AAABBBCCCNetwork RequestedEEEwwrrFFFGGNetwork IDZZJJJKKHN!
2saasBBBYes22
3saasNo44
4saasYes55
5saasNo
6saasYes
7saasYes66
8saasYes
9saasYes45
10saasYes
11saasYes
Sheet5

Data range assumed is up to column BZ, change as required in code.
VBA code.
VBA Code:
Sub HighlightID()
Dim Ip As Range, hdr As Range
Dim Lr&, T&, ClmNR&, ClmID, P$
Dim M

Lr = Range("A" & Rows.Count).End(xlUp).Row
Set Ip = Range("A2:BZ" & Lr)
Set hdr = Range("A1:BZ1")

ClmNR = WorksheetFunction.Match("Network Requested", hdr, 0)
ClmID = WorksheetFunction.Match("Network ID", hdr, 0)
P = "transpose(If((" & Ip.Columns(ClmNR).Address & "=""Yes"")*(" & _
    Ip.Columns(ClmID).Address & "=""""),Row(" & Ip.Columns(ClmNR).Address & "),False))"
M = Filter(Evaluate(P), False, False)
For T = 0 To UBound(M)
Cells(M(T), ClmID).Interior.Color = 65535
Next T

End Sub
Thank you, that worked just as I needed it to!
 
Upvote 0

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top