This is my first post.
I have spent the better part of the day trying to adapt some of the code found here.
What I want to accomplish is to clear a range of cells if the value of another cell does not equal a specific value.
I have been able to get a macro to work but it is manual.
I need the cells to be cleared automatically
I have a cell C7 that could be any value from 1 to 30.
Cell D7="30"
If C7 <> D7 then Range J7:J29 = "" and Range H9:H16 = ""
Here is the code I have gotten to work manually
Option Explicit
Sub testme()
Dim rng1 As Range
Dim rng2 As Range
Dim rng3 As Range
Dim rng4 As Range
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com
ffice
ffice" /><o
></o
>
Set rng1 = Range("C7")
Set rng2 = Range("D7")
Set rng3 = Range("J7:J29")
Set rng4 = Range("H9:H16")
If LCase(rng1.Value) <> (rng2.Value) Then
rng3.clearcontents
rng4.clearcontents
End If
End Sub
I have attempted to adapt this code to a change event unsuccesfully.
Any assistance would be greatly appreciated.
------
Bill
I have spent the better part of the day trying to adapt some of the code found here.
What I want to accomplish is to clear a range of cells if the value of another cell does not equal a specific value.
I have been able to get a macro to work but it is manual.
I need the cells to be cleared automatically
I have a cell C7 that could be any value from 1 to 30.
Cell D7="30"
If C7 <> D7 then Range J7:J29 = "" and Range H9:H16 = ""
Here is the code I have gotten to work manually
Option Explicit
Sub testme()
Dim rng1 As Range
Dim rng2 As Range
Dim rng3 As Range
Dim rng4 As Range
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com




Set rng1 = Range("C7")
Set rng2 = Range("D7")
Set rng3 = Range("J7:J29")
Set rng4 = Range("H9:H16")
If LCase(rng1.Value) <> (rng2.Value) Then
rng3.clearcontents
rng4.clearcontents
End If
End Sub
I have attempted to adapt this code to a change event unsuccesfully.
Any assistance would be greatly appreciated.
------
Bill