VBA - Formatting range based on formula / rows count

The Great SrH

Board Regular
Joined
Jan 16, 2015
Messages
179
Hi guys,

I'm really struggling to code / piece together a code that factors in the situations I require. I'll piece it together below:

---------

The range:

Code:
.Range(K5:BM" & .Cells(.Rows.Count, "A").End(xlUp).Row)

I need it to apply the formula based on the last piece of information in column A - but the cells it will be applied to begin in K5 and end in column BM

---------

The formula:

Code:
=AND($E5>=K$2,$D5<L$2)

I need the changes to only happen based on the above formula. This was originally from a conditional format, however, I need this to be VBA as the sheet wont stay static.

---------

The changes:

Code:
With Selection.Borders(xlEdgeLeft)
        .LineStyle = xlContinuous
        .ThemeColor = 1
        .TintAndShade = -0.14996795556505
        .Weight = xlThin
    End With

    With Selection.Borders(xlEdgeRight)
        .LineStyle = xlContinuous
        .ThemeColor = 1
        .TintAndShade = -0.14996795556505
        .Weight = xlThin
    End With

    With Selection.Interior
        .Pattern = xlSolid
        .PatternThemeColor = xlThemeColorAccent1
        .Color = 5287936
        .TintAndShade = 0
        .PatternTintAndShade = 0.799951170384838
    End With

Any help piecing this together will be great!

Thanks
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
Apologies - The formula is actually:
<l$5)[ QUOTE]
<l$5)[ CODE]

= AND ( $E5 > = K$2 , $D5 < L$2 )
(the code doesn't seem to work in CODE tags)

<l$2)<l$5)

Although im struggling to get this work as a conditional format now!</l$2)<l$5)
</l$5)[></l$5)[>
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,373
Messages
6,124,551
Members
449,170
Latest member
Gkiller

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