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

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
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,223,908
Messages
6,175,307
Members
452,633
Latest member
DougMo

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