Macro - how to copy and paste

andy-s

Board Regular
Joined
Mar 22, 2002
Messages
51
Hi,
my code below does not work, and I get an error message on the line Range("AA & NxRow").Select.

Can anyone help me?

The Cell(AA & NxRow) contains a formula, and I want the macro to copy and past the value on the same cell.


Code:
Sub Copy()
NxRow = Sheets("Database").Range("Y6") + 8
Range("AA & NxRow").Select
Selection.Copy
Range("AA & NxRow").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
End Sub


Andy-s
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Try:

Sub Copymystuff()
Dim NxRow As Integer
NxRow = Sheets("Database").Range("Y6") + 8
Range("AA" & NxRow).Copy
Range("AA" & NxRow).PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
End Sub
 
Upvote 0

Forum statistics

Threads
1,222,102
Messages
6,163,942
Members
451,866
Latest member
cradd64

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