Fill Macro Question

The Animal

Active Member
Joined
May 26, 2011
Messages
449
Hi
I have this little fill button to "Fill Colour" columns A20 to D20. If I select cell A20 it then fills all cells A20 to D20. How would it look if I wanted to select any cell in the A column to fill all cells A to D in that row I selected, So say I selected cell A600 and then used the button then all of A600 to D600 fills.

Sub NewNotRecorded()
' NewNotRecorded Macro
Range("A20:D20").Select
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 49407
.TintAndShade = 0
.PatternTintAndShade = 0
End With
End Sub

Thanks Stephen
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
Stephen,

Assuming that you want this for any single cell selected in A then...

Code:
Sub NewNotRecorded2()


If Not (Selection.Column = 1 And Selection.Cells.Count = 1) Then Exit Sub
Selection.Resize(1, 4).Interior.Color = 49407


End Sub

Hope that helps.
 
Upvote 0
Hey Tony
I have placed this on the main forum but maybe you could help with below question.
I have a fill macro that "Snakeships" was good enough to help me with that fills cells in columns A to D when you use a button created (below). Was wondering if I had the sheet protected and as I filled the cells A to D it changed those cells to Hidden so they are protected. So the sheet would start protected and the cells in question Unhidden so when I fill with below macro it would then change those cells to hidden and locked so they could not be modified without Unprotecting the sheet.



Sub NewNotRecorded2()


If Not (Selection.Column = 1 And Selection.Cells.Count = 1) Then Exit Sub
Selection.Resize(1, 4).Interior.Color = 49407


End Sub
 
Upvote 0
Supplementary question above in post #4 answered ................... HERE
 
Upvote 0

Forum statistics

Threads
1,214,998
Messages
6,122,639
Members
449,093
Latest member
Ahmad123098

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