Identifying the column of a variable ActiveCell to use in a range

ChrissyO

New Member
Joined
Jul 14, 2011
Messages
8
Hi, i am fairly new to VBA and so far this site has helped with every issue i have encountered. However, i have hit a hurdle with my latest efforts and decided to ask the question directly.

I am trying to create a macro that will copy the formula from the ActiveCell (which is variable) down the ActiveCell column to the last row on the worksheet.

I have identified the last row using data in column A (this is always static) but im having issues with combining the ActiveCell column with the identified last row for the purpose of the range.

At the moment i have this, the red is the part of the range i want to reference the ActiveCell column:


LastRow = Range("A65536").End(xlUp).Row

Range (ActiveCell).copy Destination:=Range(ActiveCell:" ???? & LastRow)


Any help would be much appreciated as im sure there is probably an easier way to do this. Like i said this is new to me but extremely interesting.

Thank you
 
Last edited:

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
Try:-
Code:
[FONT=Fixedsys]lastrow = Range("A65536").End(xlUp).Row[/FONT]
 
[FONT=Fixedsys]columnletter = Replace(Cells(1, ActiveCell.Column).Address(False, False), "1", "")[/FONT]
 
[FONT=Fixedsys]ActiveCell.AutoFill [/FONT][FONT=Fixedsys]Destination:=Range(ActiveCell.Address(0,0) & ":" & columnletter & lastrow), Type:=xlFillDefault[/FONT]
 
Last edited:
Upvote 0
Code:
Sub F()
    Range(ActiveCell, ActiveCell.End(xlDown)).Formula = ActiveCell.Formula
End Sub
 
Upvote 0
Try:
Code:
LastRow = Range("A65536").End(xlUp).Row
Range(ActiveCell, cells(LastRow, Activecell.column)).Formula = ActiveCell.Formula
 
Upvote 0
Thanks for replies guys, i am amazed at how quick people respond on here.

I tried all of them and they all worked so spoilt for choice really.

Thanks again, it really is very much appreciated.
 
Upvote 0
Use the one which looks the most instinctively understandable to you. Not mine then!

PS. I'm surprised you only got three working solutions in a whole quarter of an hour though. This forum must be slipping... :)
 
Last edited:
Upvote 0
They don't all do the same thing, by the way. End(xlDown) will not always produce the same range as your LastRow variable will.
 
Upvote 0

Forum statistics

Threads
1,224,503
Messages
6,179,135
Members
452,890
Latest member
Nikhil Ramesh

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