How can i change this macro so it uses a cell ref instead of a word?

tonywatsonhelp

Well-known Member
Joined
Feb 24, 2014
Messages
3,194
Office Version
  1. 365
  2. 2019
  3. 2016
Platform
  1. Windows
Hi Everyone,

I have this macro which work great at adding a conditional format to a area, but i can't get it to pull the conditions word from a cell

so instead of "Select Recommendations"
I'd like it to take the words in " Legal.Range("W" & Frow) " (So column W of the selection row)

everything else works but i can't get it to understand the Words, I assume it something to do with the double "" but i'm not sure what i'm supposed to do?

the cell contains just the word no speech marks like = Select Recommendations

any ideas how i can do this?
happy for the formula to be edited and changed, basically it says if cell = Select Recommendations then conditional formatting is true.

so this is the code:


VBA Code:
Sub Legal_Con_Format_Row83()
Frow = Selection.Row
Srow = Legal.Range("S" & Frow).Value
Erow = Legal.Range("T" & Frow).Value


Set Cond1 = Legal.Range("E" & Srow & ":H" & Erow)

Cond1.FormatConditions.Delete
With Cond1.FormatConditions _
 .Add(xlExpression, Formula1:="=IF($E" & Srow & "=""Select Recommendations"",TRUE)") [COLOR=rgb(226, 80, 65)]'this is the bit i'm having trouble with![/COLOR]

With .Borders
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 3 'red
End With
With .Font
.Bold = True
.ColorIndex = 3 'red
End With
With .Interior
        .PatternColorIndex = xlAutomatic
        .ThemeColor = xlThemeColorAccent6
        .TintAndShade = 0.799981688894314 'green
End With
End With
End Sub
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
Perhaps change the formula to look at that cell?

VBA Code:
.Add(xlExpression, Formula1:="=$E" & Srow & "=W" & Srow)

FWIW you don't need IF in a conditional format rule, the logical test alone is sufficient.
 
Upvote 0
Hi jason,
thnks that was nice and quick,
i'll give it a try and see what happens
Tony
 
Upvote 0

Forum statistics

Threads
1,214,605
Messages
6,120,476
Members
448,967
Latest member
visheshkotha

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