ActiveCell offset delete

W

Woodi2

I would like a code if anyone could help please to delete the contents of a
cell based on the data in another cell.
I would like it so that if the activecell offset by 4 = Mech, then
activecell offset by 10 is deleted.
I need it using activecell as it is all tied into a userform that opens on
various cells in column C, therefore I cannot reference a particular cell.
Any ideas
Thanks
 
T

Test

If ActiveCell.Offset(0, 4).Value = "Mech" Then
ActiveCell.Offset(0, 10).ClearContents
End If
 
G

Gary''s Student

Assuming horizontal offset:

Sub clearit()
With ActiveCell
If .Offset(0, 4).Value = "Mech" Then
.Offset(0, 10).Clear
End If
End With
End Sub
 
W

Woodi2

Thanks, that works great.
In answer to the first question, yes, its offset to the right.
How could I include to lock the cell in this code.
I already protect the sheet under another code so dont need to worry about
that.
 
G

Gary''s Student

To lock the cleared cell:

Sub clearit()
With ActiveCell
If .Offset(0, 4).Value = "Mech" Then
.Offset(0, 10).Clear
.Offset(0, 10).Locked = True
End If
End With
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top