inkserious
Technical User
- Jul 26, 2006
- 67
I have a worksheet that has multiple ranges that have to be cleared. The ranges are non consecutive and currently have to be selected by hand and be cleared. They have a pattern: every third column and every 4th and 5th row need to be skipped. So I need to begin at cell F5 and select F5:G7 and ClearContents. And then skip column H, and then select I5:J7 and ClearContents. This needs to be completed through the range CR5:CS7.
I then need to start over at row 10 and begin the same process with the last ranges beginning at F215:G217 and ending at CR215:CS217.
To complicate matters, every 5th row must be completely cleared beginning with row 9. So F9:CT9, and then F14:CT14 all the way through F219:CT219
I recorded a macro just selecting a few of the ranges to get an idea of how it might look, but after looking at the code I know there must be a much more efficient way of doing things.
Any help would be greatly appreciated.
Thanks in advancd. -edward
I then need to start over at row 10 and begin the same process with the last ranges beginning at F215:G217 and ending at CR215:CS217.
To complicate matters, every 5th row must be completely cleared beginning with row 9. So F9:CT9, and then F14:CT14 all the way through F219:CT219
I recorded a macro just selecting a few of the ranges to get an idea of how it might look, but after looking at the code I know there must be a much more efficient way of doing things.
Any help would be greatly appreciated.
Thanks in advancd. -edward
Code:
Sub ClearRanges()
Range("F9:CT9,F14:CT14").Select
Range("CT14").Activate
Selection.ClearContents
Range("F5:G7,I5:J7,L5:M7,F10:G12,I10:J12,L10:M12,F15:G17,I15:J17,L15:M17"). _
Select
Range("L15").Activate
Selection.ClearContents
End Sub