Runtime error 9 excel macro

Cravengame

New Member
Joined
May 8, 2018
Messages
3
I'm not sure what I'm doing wrong when entering this code, but I did use it before and I'm not sure what I did the last time. Basically what i'm trying to do is to copy a range of columns and paste them into another set of columns. When I type the macro the error comes up for the first line.

Private Sub CommandButton11_Click()
Sheets("NEW VENDOR SUMMARY").Range("Z3:Z866").Delete (<- this line is yellow)
Sheets("NEW VENDOR SUMMARY").Range("M3:M").Copy
Sheets("NEW VENDOR SUMMARY").Range("Z3").PasteSpecial (xlPasteValues)
Application.CutCopyMode = False


Sheets("NEW VENDOR SUMMARY").Range("L3:L").Copy
Sheets("NEW VENDOR SUMMARY").Range("M3").PasteSpecial (xlPasteValues)
Application.CutCopyMode = False


Sheets("NEW VENDOR SUMMARY").Range("K3:K").Copy
Sheets("NEW VENDOR SUMMARY").Range("L3").PasteSpecial (xlPasteValues)
Application.CutCopyMode = False


Sheets("NEW VENDOR SUMMARY").Range("J3:J").Copy
Sheets("NEW VENDOR SUMMARY").Range("K3").PasteSpecial (xlPasteValues)
Application.CutCopyMode = False


Sheets("NEW VENDOR SUMMARY").Range("I3:I").Copy
Sheets("NEW VENDOR SUMMARY").Range("J3").PasteSpecial (xlPasteValues)
Application.CutCopyMode = False


Sheets("NEW VENDOR SUMMARY").Range("H3:H").Copy
Sheets("NEW VENDOR SUMMARY").Range("I3").PasteSpecial (xlPasteValues)
Application.CutCopyMode = False




Sheets("NEW VENDOR SUMMARY").Range("G3:G").Copy
Sheets("NEW VENDOR SUMMARY").Range("H3").PasteSpecial (xlPasteValues)






MsgBox "Data Updated"


End Sub
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Hi & welcome to MrExcel.
Not sure why your code would fail on the 1st line, but all your .copy lines are wrong
Code:
Sheets("NEW VENDOR SUMMARY").Range("[COLOR=#ff0000]M3:M[/COLOR]").Copy
The part in red is not a valid range as you haven't specified a row value for the 2nd M
 
Upvote 0
Hey I fixed that. I realized i copied them wrong when i posted them. I was trying a whole bunch of other things to see if it would work. Thanks for the help.
 
Upvote 0
Glad you got it sorted & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,224,819
Messages
6,181,153
Members
453,021
Latest member
Justyna P

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