Probably the Easiest Question to Answer...

cizzln

New Member
Joined
Dec 15, 2012
Messages
2
So, I feel a little dumb asking this, but I've tried to work on it and figure it out all day to no avail, and I figure this is the quickest way to get an answer...

I wrote this code on a machine running excel 2003 and everything seemed to work fine, but I brought it to my iMac at home running 2011 and I seem to get an out of range erro every time I try to run it:

For counter = 1 To 100
Workbooks("test").Sheets("Sheet1").Range("A" & counter & ":K" & counter).Value = Workbooks("test2").Sheets("Sheet1").Range("A" & counter & ":K" & counter).Value
Next counter

I'm just trying to copy a list from one workbook to another one and for some reason, not being able to do it... HELP!!! Thanks!
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
My guess is to include the file name extensions in the workbook references e.g.; Workbooks("test.xls")

Also you can do this without the For-Next loop though this is not the error problem.

Workbooks("test.xls").Sheets("Sheet1").Range("A1:K100").Value = Workbooks("test2.xls").Sheets("Sheet1").Range("A1:K100").Value

Also note, If say test.xls is the workbook with the workbook with the macro, you can reference it using ThisWorrkbook keyword

ThisWorkbook.Sheets("Sheet1").Range("A1:K100").Value = Workbooks("test2.xls").Sheets("Sheet1").Range("A1:K100").Value
 
Last edited:
Upvote 0
Sadly, I tried adding the extension, and that did not work... I tried it again, after your suggestion, and realized that test2 was actually .xlsx... I wish there were a facepalm emoticon...
 
Upvote 0

Forum statistics

Threads
1,214,945
Messages
6,122,393
Members
449,081
Latest member
JAMES KECULAH

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