VBA newbie-copy range from one workbook to another

findeep

New Member
Joined
Nov 17, 2011
Messages
7
Hi, struggling out here in Nigeria without much help...trying to copy a range of cells from one worksheet (protected) to a new sheet in another workbook. Wrote it in Excel 2003 and then discovered the client machines are 2002 and I now get an error when I try to copy:


Set NewBook = Workbooks.Add
With NewBook
.SaveAs Filename:=FileNme
End With
'Now copy the required data to blanks sheet in new workbook
BkNme = Workbooks(Workbooks.Count).Name
Workbooks(OpenedLogFile).Worksheets("Ops").Range("B9:O400").Copy Destination:=Workbooks(BkNme).Sheets(1).Range("A1")
ActiveWorkbook.Close SaveChanges:=False

OpenedLogFile is a string populated from the filename of the workbook I'm copying from

Hope someone can point me in the right direction please

Max:eek:
 
MGM

many thanks but still causes runtime error-it must be a problem between VBA for Excel 2003 in which I wrote the code and Excel 2002 where I am trying to run the code.
 
Upvote 0

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.

Forum statistics

Threads
1,214,864
Messages
6,121,986
Members
449,060
Latest member
mtsheetz

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