Formatting Cells

ai1094

Board Regular
Joined
Aug 23, 2018
Messages
92
I have the current VBA code below:

Range("N82:S82").Select
Range(Selection, Selection.End(xlDown)).Select
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorAccent4
.TintAndShade = 0.399975585192419
.PatternTintAndShade = 0
End With

I am trying to only fill the selected range up until the last row of data MINUS ONE (-1) row. Is there a simple way to execute this code?
*Last row of data can be found in Col A
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
Try
Code:
Range(Selection, Selection.End(xlDown)[COLOR=#ff0000].Offset(-1)[/COLOR]).Select
 
Upvote 0
It still fills the range of cells until the very last row excel goes up to (millions). I need it to calculate the last row that can be found in Col A

Try
Code:
Range(Selection, Selection.End(xlDown)[COLOR=#ff0000].Offset(-1)[/COLOR]).Select
 
Last edited:
Upvote 0
Ok, how about
Code:
Sub ai1094()
With Range("N82:S" & Range("A" & Rows.Count).End(xlUp).Offset(-1).Row).Interior
   .Pattern = xlSolid
   .PatternColorIndex = xlAutomatic
   .ThemeColor = xlThemeColorAccent4
   .TintAndShade = 0.399975585192419
   .PatternTintAndShade = 0
End With
End Sub
 
Upvote 0
This is great. Thank you!

Ok, how about
Code:
Sub ai1094()
With Range("N82:S" & Range("A" & Rows.Count).End(xlUp).Offset(-1).Row).Interior
   .Pattern = xlSolid
   .PatternColorIndex = xlAutomatic
   .ThemeColor = xlThemeColorAccent4
   .TintAndShade = 0.399975585192419
   .PatternTintAndShade = 0
End With
End Sub
 
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,214,601
Messages
6,120,465
Members
448,965
Latest member
grijken

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