With this code:
Always try and avoid selecting sheets and ranges, it's very slow and unnecessary. If you refer to the sheet and the range then you don't need to select it.
With code such as the following:
Since we have the with line we know that everything with just a . in front of it refers to what we mentioned in the with line.
so .range refers to Worksheets(arrSheetsNames(j)), so whatever worksheet we are talking about in the array that is the .range we are referring to.
You notice in the code:
I am using ws2.Range because if I put .range without specifying the worksheet it will refer to the worksheet we are talking about using the With statement. Make sense?
No selecting sheets or ranges necessary. Imagine that manually you copy some cells on a sheet and then you select another sheet, then select a range and then choose paste, how fast is that? Now imagine just being able to say computer on sheet 2 copy range x and paste it to sheet 3 range y. That's the speed difference in the code.
Now notice the code you added below.
What sheet is the Range you are referring to on? What sheet did you intend to use? If you do not specify a sheet then it will use the sheet that is active at the time these lines of code are run. I would suggest you specify the sheet you want these numbers to come from in the code. No need to activate the sheet or select the range, just specify the sheet name and range as I have shown you elsewhere in the code.
I apologize for not replying to you, I was no longer watching this thread. I am now, so please make changes and use any knowledge you may have gained from this post to try and solve your problem.
Let me know if you need any further assistance.
Thanks for the rep. points, that's how I knew to come back here and look at this thread.
Bookmarks