ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   For Next issue with repeated procedure (https://www.excelbanter.com/excel-programming/437334-re-next-issue-repeated-procedure.html)

Dave Peterson

For Next issue with repeated procedure
 
Check your other post.

ccfcrup wrote:

I have the procedure below. Basically I don't want to have
interminable lines of code when all I am doing is repeating the same
procedure on a differnet range. How can I write the procedure that it
loops through the procedure with the 6 different ranges

rng1 = "A1:A9"
rng2 = "A11:A20"
Rng3 = "A30:A34"
Rng4 = "A40:A48"
Rng5 = "A50:A59"
Rng6 = "A65:A69"

n = 6

For i = 1 To n

ActiveCell.Range(rng(i)).Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues
Application.CutCopyMode = False
Next i

Thanks

Rup


--

Dave Peterson


All times are GMT +1. The time now is 02:07 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com