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
2,679
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
 

Some videos you may like

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.

jasonb75

Well-known Member
Joined
Dec 30, 2008
Messages
11,958
Office Version
  1. 365
Platform
  1. Windows
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.
 

tonywatsonhelp

Well-known Member
Joined
Feb 24, 2014
Messages
2,679
Office Version
  1. 365
  2. 2019
  3. 2016
Platform
  1. Windows
Hi jason,
thnks that was nice and quick,
i'll give it a try and see what happens
Tony
 

Watch MrExcel Video

Forum statistics

Threads
1,122,822
Messages
5,598,304
Members
414,224
Latest member
Crazy_FC

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
Top