clearcells based on value in cell on another sheet

CarDyer

New Member
Joined
Feb 4, 2017
Messages
8
Hi
Struggling with this and cant find anything on google.

I have a few sheets in a workbook for a game we play. One sheet per person and a TOTALS sheet. Values get added to each person sheet during the game in a specific range of cells, e.g. D3-D7 and G6-G11.

At the end of the game I want to issue a command to clear all the values from the person sheets for the ranges specified. I am guessing that the best way to do this is to have a cell in the TOTALS sheet in which I can enter a 'Y', but open to other suggestions.

I have found solutions to include a cell on each of the sheets but not one that covers updating all sheets in the one go.

Any help greatly appreciated as emptying the cells manually really impinges on our gambling time :laugh:
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
hello, maybe something like this? cheers
Code:
'one approach
Const sRANGES_TO_CLEAR As String = "D3:D7,G6:G11"
Dim wksLoop As Excel.Worksheet

For Each wksLoop In Worksheets
    Select Case wksLoop.Name
        Case "TOTALS"
            'do nothing
        Case Else
            wksLoop.Range(sRANGES_TO_CLEAR).ClearContents
    End Select
Next wksLoop
Set wksLoop = Nothing
 
Last edited:
Upvote 0
hello, maybe something like this? cheers
Code:
'one approach
Const sRANGES_TO_CLEAR As String = "D3:D7,G6:G11"
Dim wksLoop As Excel.Worksheet

For Each wksLoop In Worksheets
    Select Case wksLoop.Name
        Case "TOTALS"
            'do nothing
        Case Else
            wksLoop.Range(sRANGES_TO_CLEAR).ClearContents
    End Select
Next wksLoop
Set wksLoop = Nothing

Thank you Fazza. Unfortunately that is not working for me. I am getting a runtime error 1004 Intersect of object Global failed.

I lifted your code and put it in a sub and tried to run.

I cannot see where I would enter the 'Y' in a cell in the TOTALS sheet to do the clear.

Also the sheets are named. Does that make a difference?
Thanks
 
Upvote 0
You're welcome.
I don't know why there is the error.
I also cannot see where you'd enter the "Y".
Sheets named is unavoidable - no difference.
cheers
 
Upvote 0

Forum statistics

Threads
1,224,742
Messages
6,180,685
Members
452,993
Latest member
FDARYABEE

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