Hello:
I am using below code and it is giving "Subscript out of range" error.
Would appreciate help to resolve
Please let me know if you have any questions.![]()
Please Login or Register to view this content.
Thanks.
Riz
Hello:
I am using below code and it is giving "Subscript out of range" error.
Would appreciate help to resolve
Please let me know if you have any questions.![]()
Please Login or Register to view this content.
Thanks.
Riz
At what line do you get that message? And what does variable contain?
That message is likely result of workbook/sheet name not being found.
"Progress isn't made by early risers. It's made by lazy men trying to find easier ways to do something."
― Robert A. Heinlein
Most likely on this line
ThisWorkbook.Sheets(CSheet).Range("C" & PasteR).Resize(RowsCnt, ColsCnt) = SrcRng.Value
What is the value of CSheet = Range("K2").Value? Is it a string? Sheets(CSheet) name should be a string.
What ever value is in K2 should match with existing sheet name. If it does not, the sheet names does not exist.
Last edited by AB33; 11-10-2017 at 11:04 AM.
Hello:
Below are all defined:
![]()
Please Login or Register to view this content.
Riz,
In which line does the code error? Did you read my post 3?
Hello:
AB33 : It does not show where the error occurs.
Also all of them are defined and are according to your Post#3
Just to let you know that once i press ok at the error, the macro will complete running and bring get the correct result.
Its just annoying getting the error as i am designing to running this macro in a loop with lots of data/
Please help to by-pass this error or may be help with new code.
Please let me know if you have any questions.
Thanks.
Riz
Riz,
Well, the code should come to halt as soon as it encounters an error.
ThisWorkbook.Sheets(CSheet)=Range("K2").Value
Let's say you have Range("K2").Value as sheet1 or riz .
You should have a sheet name called sheet1 or riz in your sheet name collections.
Any other I can think of is, you may rows exceeding 32k, in that case, you need to change the variables from integer to long.
Hello Guys:
I found the problem and have resolved the issue.
The problem was that when closed worksheet was being opened, it had the code to land at certain sheet and that sheet did not exist.
Once again thanks a lot to point me to the right direction.
Riz
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks