having problem with the macro recorder and Shift+End Down

still learning

Well-known Member
Joined
Jan 15, 2010
Messages
838
Office Version
  1. 365
Platform
  1. Windows
This is a sample to show the problem I’m having

I have data in A1:H25 that has a fill of light blue
Using the macro recorder, I click on the relative reference
I then Click> Shift + End Down and move to the right 8 cells
This high lights A1:H25
I then format the cells as “No fill” and shut off the recorder
I then add five more cells down and 8 to the right
And format the new cells with a fill
I then run the macro putting the cursor on A1 and the macro runs perfect
BUT only to A1:H25 not A1:H33
The new 5 rows are still formatted with a fill
VBA Code:
Sub Macro8()
    Range(Selection, Selection.End(xlDown)).Select
    ActiveCell.Range("A1:H21").Select
    With Selection.Interior
        .Pattern = xlNone
        .TintAndShade = 0
        .PatternTintAndShade = 0
    End With    
End Sub

What I’m trying to do is change the fill format of the results of an advance search result. The results will not always have the same number of rows.
I don’t know how to change “ ActiveCell.Range("A1:H21").Select “
to match the “Selection.End(xlDown)).Select”

mike
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
Use this instead, should be enough. It will resize the active selection (A1:A33) by 8 columns to the right (H):
VBA Code:
Selection.Resize(, 8).Select
 
Last edited:
Upvote 0
Solution

Forum statistics

Threads
1,225,609
Messages
6,185,980
Members
453,333
Latest member
BioCoder84

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