We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

Subscript out of range error

Seamus2626
Seamus2626 asked
on
Medium Priority
221 Views
Last Modified: 2012-05-11
Hi,

I have the following line of code to copy/paste data from one spreadsheet to another

Im getting subscript out of range

The sheet "Prime Dividends Checker.xls" & sheet "PAID DIVS" are there.

Can anyone see why?

Thanks
Seamus




ThisWorkbook.Sheets("Sheet1").Range("A1").CurrentRegion.Copy _
        Workbooks("Prime Dividends Checker.xls").Sheets("PAID DIVS").Range("A" & Rows.Count).End(xlUp)(2)

Open in new window

Comment
Watch Question

CERTIFIED EXPERT
Most Valuable Expert 2011
Top Expert 2011
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION

Author

Commented:
Its worth mentioning ThisWorkbook is referring to a ss called "OPEN DIV RAW DATA" which is open and active

Does that make any difference?

I didnt think it would as this part of the code refers to the sheet i want to paste the data too
Copy _
        Workbooks("Prime Dividends Checker.xls").

Author

Commented:
Got rid of ThisWorkbook!

Thanks
Seamus
CERTIFIED EXPERT
Most Valuable Expert 2011
Top Expert 2011

Commented:
ThisWorkbook always refers to the workbook containing the code, not the active workbook.
ThisWorkbook always refers to the workbook containing the code. If this is not the case you will have to replace ThisWorkbook with the name of the workbook from which you are copying.
May be word for word but I swear I did not see your post rory!
CERTIFIED EXPERT
Most Valuable Expert 2011
Top Expert 2011

Commented:
No probs. :)
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.