Help to ClearContents by Columns based on cell value

georgede

New Member
Joined
Sep 13, 2019
Messages
4
Hi all,
What i am looking to do seems simple enough but i just dont have the expertise to figure out the VBA for it, any help would be greatly appreciated!

I would like to evaluate a cell (B7) where if the value = "SUN" or value = "SAT" and then clearcontents of range B9:B37 if that value is TRUE, then move to column C eval C7 and clearcontents of range C9:C37 if TRUE. All the way through Column AF.

I hope this is as simple as i thought it was, many thanks!
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
Welcome to the Board!

Try this:
Code:
Sub MyMacro()

    Dim cell As Range
    
    Application.ScreenUpdating = False
    
    For Each cell In Range("B7:AF7")
        If (cell = "SAT") Or (cell = "SUN") Then
            Range(cell.Offset(2, 0), cell.Offset(30, 0)).ClearContents
        End If
    Next cell
    
    Application.ScreenUpdating = True
    
End Sub
 
Upvote 0
First thank you for the welcome and more importantly this works PERFECTLY. I was definitely trying to over complicate it. This does exactly what i need.

Many thanks,
George
 
Upvote 0
You are welcome.
Glad I was able to help!
:)
 
Upvote 0

Forum statistics

Threads
1,224,816
Messages
6,181,139
Members
453,021
Latest member
Justyna P

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