Paste to last row

Mark F

Well-known Member
Joined
Jun 7, 2002
Messages
504
I have the following code

Selection.Copy
Range("F2:F26").Select
ActiveSheet.Paste

The code copies into range F2:F26. I would like to copy to between f2 and the last row of the sheet

I know this involves Xlup but cannot work out how

Can you help

Thanks

Mark
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)

Mark F

Well-known Member
Joined
Jun 7, 2002
Messages
504
Hi

I just want to copy a formula that is in F2 all the way to the last row

Thanks

Mark
 
Upvote 0

njimack

Well-known Member
Joined
Jun 17, 2005
Messages
7,772
Based on your request, the following should work (assumes you're copying column A - change as needed).
Code:
Sub Copy_and_Paste()
Dim End_Row as Long

End_Row = Range("A" & Rows.Count).End(xlUp).Row

Range("A2:A" & End_Row).Copy Destination:=Range("F2:F26")
Application.CutCopyMode = False
End Sub
 
Upvote 0

Richard Schollar

MrExcel MVP
Joined
Apr 19, 2005
Messages
23,707
Hi

I just want to copy a formula that is in F2 all the way to the last row

Thanks

Mark

Hi Mark

So you are copying a single cell and want to copy it to F2:F65536? Or how are you defining the last row? Is it based on some adjacent column that contains values?
 
Upvote 0

Mark F

Well-known Member
Joined
Jun 7, 2002
Messages
504
Sorry

Should have made it clearer.

I am looking to copy the formula that is in f2 all the way down column f to the last active row (xlup?), There will be contents in column A

MArk
 
Upvote 0

njimack

Well-known Member
Joined
Jun 17, 2005
Messages
7,772
Try this...

Code:
Sub Copy_and_Paste() 
Dim End_Row as Long 

End_Row = Range("A" & Rows.Count).End(xlUp).Row 

Range("F2).Copy Destination:=Range("F3:F" & End_Row) 
Application.CutCopyMode = False 
End Sub
 
Upvote 0

Richard Schollar

MrExcel MVP
Joined
Apr 19, 2005
Messages
23,707
A minor variation on Neil's code will suffice:

Code:
Sub Copy_and_Paste()
Dim End_Row as Long

End_Row = Range("A" & Rows.Count).End(xlUp).Row

Range("F2").Copy Destination:=Range("F2:F" & End_Row)
Application.CutCopyMode = False
End Sub
 
Upvote 0

Forum statistics

Threads
1,191,005
Messages
5,984,121
Members
439,872
Latest member
noaman79

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
Top