Highlight in red all cells that have a formula with a mixed reference.

Josecarlospdcj

New Member
Joined
Sep 1, 2023
Messages
6
Office Version
  1. 2010
class=y2iqfc>Hello everybody!
style='font-size:12.0pt;font-family:"inherit",serif;color:#202124;mso-ansi-language:
EN'>
I'm a beginner in VBA. I tried to change the code that is being shown in "VBA - highlight cells with absolute references" but I couldn't adapt to what I need.
style='font-size:12.0pt;font-family:"inherit",serif;color:#202124;mso-ansi-language:
EN'>I have a spreadsheet with more than 1000 cells in which there are formulas with variations between relative and/or mixed and/or absolute references.
style='font-size:12.0pt;font-family:"inherit",serif;color:#202124;mso-ansi-language:
EN'>I need to highlight in red only those cells that have at least one formula with mixed reference, regardless of whether this same cell also has, along with the mixed reference, formulas with relative and/or absolute references.style='font-size:12.0pt;font-family:"inherit",serif;color:#202124'>

The most recent attempt also did not work because it paints red only the 1st cell with a dollar sign, not differentiating those that have mixed and/or absolute references.

Dim r As Range

Worksheets("Plan1k").Activate
With ActiveSheet.UsedRange
.Interior.ColorIndex = xlNone
Range("A1:A16").Find(What:="$").Interior.ColorIndex = 3
End With
End Sub
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
welcome to the forum, try this:
VBA Code:
Sub test2()
Dim r As Range
Dim c As Range

Worksheets("Plan1k").Activate
Set r = ActiveSheet.UsedRange
With r
.Interior.ColorIndex = xlNone
End With
For Each c In r
 If InStr(c.Formula, "$") > 0 Then
  c.Interior.ColorIndex = 3
 End If
Next c

End Sub
 
Upvote 0
Thanks for the welcome and response.
The VBA code painted red all the cells that have formulas with a dollar sign, including the cells that only have formulas with absolute references (Ex.: =$A$1+$A$2) and that's where it doesn't meet what I need at the moment.
I need only the cells in which at least one of the formulas have a mixed reference (Ex.: =$A$1+$A2) or only a mixed reference (Ex.: =$A1+A$2) to be colored red.
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,334
Members
452,636
Latest member
laura12345

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