Cut and Paste, VB

G

Guest

Hi,

I recorded my step-by-step entries and changed some of the commands as
follows:

Sub Macro1()
'Range("Q95:Q99").Select = This code was replaced with:
Range("Mo_401k").Select
Application.CutCopyMode = False
Selection.Cut
'Range("Q96").Select = This code was replaced with:
ActiveCell.Offset(1, 0).Select
ActiveSheet.Paste
End Sub

Even if i don't change some of the commands, the macro does not run and
always highlights "Activesheet.Paste" as the error.

Please help
 
D

Don Guillett

a bit simpler. Change range to your range name and the destination cell.
Sub cutpaste()
Range("d2:d5").Cut Destination:=Range("c2")
End Sub
 
G

Guest

Thank you for your response. The destination is one cell down (variable
range). How will I properly address one cell down?

Thanks again.
 
G

Guest

Thanks again for your prompt response Don. However, it did not work. I even
replaced my named range to the actual range.
 
D

Don Guillett

I just re-tested both of these and they worked just fine. Moved the range to
the new cell, one down.
Sub cutpaste()
'Range("d2:d5").Cut Destination:=Range("c2").Offset(1)
Range("cpyrng").Cut Destination:=Range("c2").Offset(1)
End Sub

Post YOUR code for us to see and RE-state EXACTLY what you are trying to do
 
G

Guest

Hi Don,

Sub cutpaste()
' (1) Range("d2:d5").Cut Destination:=Range("c2").Offset(1)
Range("mo_401k").Cut Destination:=Range("mo_401k").Offset(1)
End Sub

(1) I replaced ("d:d5") with my named range ("mo_401k") - this can be
anywhere in the worksheet so, the destination "=Range("c2")" does not apply.

If you look at the step-by-step recorded macro I did, all I need is to cut
the Named Range "mo_401k", move one cell/row down and paste it.

The destination range you provided above moves to the right and one cell/row
down.

Thanks again.
 
D

Don Guillett

Golly, Couldn't you just use range("d2").offset(1)
Am I missing something here?
 
G

Guest

As I said, my named range can be anywhere, e.i., f2:f5 or a12:a15, etc., so,
how can I address the variable of "d2".

All I need is to cut the named range and paste it one cell/row below. Thanks
again.



Don.
 
D

Don Guillett

You NEVER said so. "can be anywhere"
If your named range was d2:d5 this will move it to d6:d9

Sub cutpaste1()
lr = Application.CountA(Range("thsrng")) 'assumes no blanks
Range("thsrng").Cut Destination:=Range("thsrng").Cells(1 + lr, 1)
End Sub
 
D

Don Guillett

If you only want to move d2:d5 to d3:d6 then
Sub cutpaste1()
Range("thsrng").Cut Destination:=Range("thsrng").Cells(2, 1)
End Sub
 
G

Guest

Hi Don,

I did say "this can be anywhere in the worksheet". Anyway, it works
perfectly now.
Thank you for your time and effort. Have a great weekend and Thanksgiving!

Danny
 
D

Don Guillett

Always best to state all contingencies at the outset.
Have a great weekend and Thanksgiving
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top