filling down to last cell in row

chriss09

New Member
Joined
Nov 7, 2011
Messages
9
I've seen so many fill down codes but have had no success in making them work for my situation. Below is a recorded macro. I'm trying to edit the part when it fills down. I need it to select cells C2:H2 down to the last row of the sheet (i guess based on column A, this will always have data to the bottom of the active sheet with no gaps)

Code:
Sub Macro2()
'
' Conditional Formatting fills right then down
'
'
    Range("C2").Select
    Selection.FormatConditions.Add Type:=xlExpression, Formula1:="=L2<=0"
    Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
    With Selection.FormatConditions(1).Font
        .Color = -16776961
        .TintAndShade = 0
    End With
    With Selection.FormatConditions(1).Interior
        .PatternColorIndex = xlAutomatic
        .ThemeColor = xlThemeColorDark1
        .TintAndShade = -0.249946592608417
    End With
    Selection.FormatConditions(1).StopIfTrue = False
    Range("C2:H2").Select
    Selection.FillRight
'this part below
    Selection.AutoFill Destination:=Range("C2:H130"), Type:=xlFillDefault
    Range("C2:H130").Select
End Sub

Please show me the way :)
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
Welcome to the Board!

See if this does it:

<font face=Calibri>    <SPAN style="color:#00007F">Dim</SPAN> LR <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Long</SPAN><br>    <br>    LR = Cells(Rows.Count, "A").End(xlUp).Row<br>    <br>    <SPAN style="color:#00007F">With</SPAN> Range("C2:H2")<br>        .FillRight<br>        .AutoFill Destination:=Range("C2:H" & LR), Type:=xlFillDefault<br>    <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">With</SPAN><br></FONT>

HTH,
 
Upvote 0
Perfect!!!!! Thank you so much. Just started messing with vba and have been searching for that part for two days....THANK YOU!!!
 
Upvote 0

Forum statistics

Threads
1,214,585
Messages
6,120,388
Members
448,957
Latest member
Hat4Life

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