Simple ClearContents not working

ColinCoady

New Member
Joined
Mar 21, 2019
Messages
35
I can't figure out why this won't work. Can someone take a look?

Code:
Private Sub ClearContents()
Worksheets("Costing").Activate
If Cells(7, 5).Value = "Other %" Then Cells(7, 7).ClearContents
End Sub
 
I can't figure out why this won't work. Can someone take a look?

Code:
Private Sub ClearContents()
Worksheets("Costing").Activate
If Cells(7, 5).Value = "Other %" Then Cells(7, 7).ClearContents
End Sub
Describer "won't work" for us... what exactly happens?
 
Upvote 0

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
What does this formula return?
=CODE(RIGHT(E7))
 
Upvote 0
Hi

Where is this code, in a sheet module or in a general module?

If it's in a sheet module use instead:

Code:
Private Sub ClearContents()

If Worksheets("Costing").Cells(7, 5).Value = "Other %" Then Worksheets("Costing").Cells(7, 7).ClearContents
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,286
Members
452,631
Latest member
a_potato

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