VBA filldown with dynamic range

sjk1193

New Member
Joined
Nov 12, 2018
Messages
29
abc
1
1 on LTD.

<tbody>
</tbody>
31354Q1
2
2 on LTD.

<tbody>
</tbody>
425Q1
3
31 on LTD.

<tbody>
</tbody>
452Q1
4
51 on LTD.

<tbody>
</tbody>
76Q1
5
8 on LTD.

<tbody>
</tbody>
456786Q1
6
65 on LTD.

<tbody>
</tbody>
475Q3
7
68 on LTD.

<tbody>
</tbody>
98
8
989 on LTD.

<tbody>
</tbody>
475453
9
6584 on LTD.

<tbody>
</tbody>
4534
10
56 on LTD.

<tbody>
</tbody>
86876

<tbody>
</tbody>


I' trying to fill down column C based on that last value in that column and then stop when column B has no more values. So far I have the code below that fills down all of column C with "Q1".

Dim lastRow As Long
With Sheet5
lastRow = .Cells(Rows.Count, "A").End(xlUp).Row
.Range("C1:C" & lastRow).FillDown
End With



Then i paste more values though and now need it to fill down the values with "Q3" . I think I need to replace the "C1:C" so that it is dynamic and now selects the value in C6

<colgroup><col><col span="2"><col><col></colgroup><tbody></tbody>
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
How about
Code:
With Sheet5
   .Range(.Range("C" & Rows.Count).End(xlUp), .Range("B" & Rows.Count).End(xlUp).Offset(, 1)).Filldown
End With
 
Upvote 0
Is this what you are looking for?
Code:
    Dim firstRow As Long
    Dim lastRow As Long
    
    With Sheet5
        firstRow = .Cells(Rows.Count, "C").End(xlUp).Row
        lastRow = .Cells(Rows.Count, "A").End(xlUp).Row
        .Range("C" & firstRow & ":C" & lastRow).FillDown
    End With
 
Upvote 0

Forum statistics

Threads
1,215,029
Messages
6,122,760
Members
449,095
Latest member
m_smith_solihull

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