Copy Absolute(always same), Paste Relative (current cell)

drewbsking

New Member
Joined
Nov 3, 2011
Messages
34
The following code is the start of what I am trying to do. I want to always copy the entire row A155 and paste it to the active cell row (the cell that is currently selected when the macro is started). The problem however as soon as it selects the row to be copied my active row changes. I would like to accomplish this without any inputboxes. Any suggestion?!



Code:
Sub StdCopy()

Dim SelectedROW As Long

SelectedROW = ActiveCell.Row

Range("A155:A155").EntireRow.Select
Selection.Copy


'Option 1
'===This does not work, it paste right back to the copied row.
ActiveCell.EntireRow.Select
Selection.Paste
'===

'Option 2
'+++This does not work, I dont think I can mix absolute and relative code within the same macro. Plus it  simply does not work.  It errors out at this line.


cells(SelectedROW,0).EntireRow.Selection
Selection.Paste


End Sub
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
Try

Code:
Sub StdCopy()
Rows(155).Copy Destination:=Range("A" & ActiveCell.Row)
End Sub
 
Upvote 0
try just the one line:
Code:
Range("A155").EntireRow.Copy ActiveCell.EntireRow
and seeing VoG's response this works too:
Code:
Rows(155).Copy ActiveCell.EntireRow
 
Last edited:
Upvote 0
All three variants work perfect. Wow one line of code is way better than the road I was going down. Thanks for your help!
 
Upvote 0

Forum statistics

Threads
1,221,310
Messages
6,159,173
Members
451,543
Latest member
cesymcox

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