Quick Macro helpl

cav~firez22

Well-known Member
Joined
Jun 21, 2006
Messages
543
If i have this
Code:
    ActiveCell.FormulaR1C1 = "ATLANTA"
    Selection.AutoFill Destination:=Range("B1:B150")

How can i get it to auto fill down to the last row of data instead of always row 150.

basically as far as there is data in colum A, i want B1 to autofill down.

could some one help me get that?

thanx
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
How's this:

<font face=Courier New><SPAN style="color:#00007F">Sub</SPAN> foo()
    <SPAN style="color:#00007F">Dim</SPAN> lastrow <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Long</SPAN>
        lastrow = Cells(Rows.Count, "A").End(xlUp).Row
        <SPAN style="color:#00007F">With</SPAN> Range("B1")
            .Value = "ATLANTA"
            .AutoFill Destination:=Range(Range("B1"), Cells(lastrow, ActiveCell.Column))
        <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">With</SPAN>
<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN></FONT>

HTH,

Smitty
 
Upvote 0
Replace both lines of code with :-

Code:
Range([B1], [A65536].End(xlUp)(1, 2)) = "ATLANTA"
 
Upvote 0
You could use the same general idea:

Code:
Range([A1], Cells(Rows.Count, "G").end(xlUp)).Copy

Just record copying something, opening the other wb and pasting to get the syntax for the rest.

Smitty
 
Upvote 0

Forum statistics

Threads
1,214,411
Messages
6,119,356
Members
448,888
Latest member
Arle8907

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