Forum Discussion
Repetitive VBA code
Hi adversi thanks for the reply. I can't paste in any more detail as its sensitive. But essentially the only think that is changing is the letters 'AG', i.e. the column label, and they are increasing by 1, about 80 times, repeating the rest of the code over and over again. The Macro works, but take a couple of minutes to process, and I'm sure there must be cleaner way of coding than repeating the whole section of code over and over again.
Appreciate if that's still not enough information!
To improve the macro, you can adjust the Range portion of the selection to expand the number of cells being copied.
In this case, if you want to copy cells from Row 27 to Row 28, starting with column AG to (hypothetical) AZ, the copy and paste macro would be:
Range("AG27:AZ27").Copy
Range("AG28:AZ28").PasteSpecial _
Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
There are more ways to optimize this code, but this elimination of individual cells being copied one at time should improve the performance