StormsEdge
StormsEdge

Reputation: 885

Trouble cutting to a destination

Trying simply to cut from one range and paste it to another neatly, rather than using paste etc. This is what I have:

Sub Format_Excel_Confirm(clientName As String, newWB As Workbook)

lRow = ActiveWorkbook.Sheets(1).Range("A60000").End(xlUp).Row
Range("B2", "B" & lRow).Cut(Range("AF2", "AF" & lRow))

and it's failing due to:

"Cut method of Range class failed" error.

Upvotes: 0

Views: 117

Answers (1)

R3uK
R3uK

Reputation: 14537

In VBA, if you use parenthesis around your arguments, it means that you will assign the value of the line to a variable.

You can cancel the return of the line with a Call on the start of your line

Or just get rid of the parenthesis around your arguments!


So Range("B2", "B" & lRow).Cut(Range("AF2", "AF" & lRow)) should be :

Call Range("B2", "B" & lRow).Cut(Range("AF2", "AF" & lRow))
'Or
Range("B2", "B" & lRow).Cut Range("AF2", "AF" & lRow)

Upvotes: 1

Related Questions