Copying and Pasting Macro

G

Guest

Hello,

I need helps on creating a macro that will copy and paste specific range
(E2:V200) from Sheet1 to Sheet 2 and so on. The script that I have does not
seem to working. Please Help!

Sub DoCopy()
Dim szRange As String
szRange = "E2:V200"
Worksheets("Data").Range
(szRange).Copy Destination:=Worksheets
("sheet2").Range(szRange)
End Sub

Thanks,
 
G

Gord Dibben

"not seem to be working" is a bit vague.

What doesn't happen or does happen when you run your macro?

Do you get errors or?

Works for me after I clean up the line wrapping.

Sub DoCopy()
Dim szRange As String
szRange = "E2:V200"
Worksheets("Data").Range _
(szRange).Copy Destination:=Worksheets _
("sheet2").Range(szRange)
End Sub



Gord Dibben MS Excel MVP
 
G

Guest

I have cleaned up the line wrap. I can compile the code, but when I run the
macro I get this message "Subscript out of range" What do I need to do in
order to get macro working properly (generating result)?
 
G

Gord Dibben

I would suggest one of your sheetnames is incorrect.

If I change "Data" to "Yata" I get a "subscript out of range" error 9


Gord
 
G

Guest

Thanks a bunch! I got it now.

Gord Dibben said:
I would suggest one of your sheetnames is incorrect.

If I change "Data" to "Yata" I get a "subscript out of range" error 9


Gord
 
G

Gord Dibben

Excellent

Those darn sheetnames with a space where it doesn't get noticed<g>

Gord
 

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