Clearing cells in a pattern

methody

Well-known Member
Joined
Jun 17, 2002
Messages
857
Hello there
I make entries on a large worksheet in the course of a year. At the end of the year I would like an automated way of clearing the information from the cells so that I can start again.

Data is entered in F10 and G10, then F11 and G11, then F12 and G12

The next entries are in F18 and G18, then F19 and G19, then F20 and G20

The next enteries are in F26 and G26, then F27 and G27, then F28 and G28

So there is a gap of 5 cells each time.
The trouble is that there are formulas in these cells so I can't just highlight the whole range and clear the cells and the entries continue until around F5000.

I can create a macro using the recorder which highlights each section individually and clears the contents bit its is a long and clumsy piece of code. Given that there is a pattern is there any way of automating it more cleanly? Thanks
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
Try like this

Code:
Sub clr()
Dim i As Long
For i = 10 To 26 Step 8
    Range("F" & i).Resize(3, 2).ClearContents
Next i
End Sub
 
Upvote 0
Sorry VoG
In order to speed it up would it be possible to build into it the idea that if the top left cell was empty eg F10, go to next i without the clearing.

Perhaps this would not make any difference.
 
Upvote 0
This should speed it up

Code:
Sub clr()
Dim i As Long
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
For i = 10 To 26 Step 8
    If Range("F" & i).Value <> "" Then Range("F" & i).Resize(3, 2).ClearContents
Next i
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,617
Messages
6,179,914
Members
452,949
Latest member
beartooth91

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top