![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Board Regular
Join Date: Mar 2002
Location: England, UK.
Posts: 526
|
Hi all.
Tonight I have been going back through some of my old macro creations and improving the efficiency of the code by doing things like: Dim nprem As Worksheet Set nprem = Sheets("NetPrem") 'then using with statements such as With nprem lengthRange = .Range(.[E1], .[IV1].End(xlToLeft)).count / 2 For k = 1 To lengthRange cellsrange(k) = .Range(.[E1].Offset(0, 2 * (k - 1)), .[E65536].Offset(0, 2 * (k - 1)).End(xlUp)).count - 1 For i = 1 To 2 For j = 1 To cellsrange(k) dynarr(i, j, k) = .[E1].Offset(j, 2 * (k - 1) + i - 1).Formula Debug.Print dynarr(i, j, k) Next j Next i Next k End With If there are any novice programmers out there, I thoroughly recommend this approach compared to select/activate sheets as it is SO MUCH FASTER, tidier and easy to debug. VBA will never be the same again. Thanks to everyone who helped me on the board tonight once more, RET79 |
|
|
|
|
|
#2 |
|
Board Regular
Join Date: Apr 2002
Location: Redmond, WA
Posts: 636
|
I agree with RET. Using activate, select are basically pointless to use.
|
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|