Tech Support Guy banner
Status
Not open for further replies.

Solved: Clearing Cell Contents Based off other Cell

894 views 2 replies 2 participants last post by  FLOVETT 
#1 ·
Hello,

I am attempting to clear 2 cells, based off the value of another. I am pretty sure the code is correct, because it works within another Macro. Thanks.

Code:
 Sub REMOVE()


Dim p As Long
p = Cells(Rows.Count, "a").End(xlUp).Row


For i = 1 To p
Range("k2").Select
If InStr(1, Range("k" & p), "None") > 0 Then Range("L" & p) = "" And Range("M" & p) = ""
                           'If no Issue, Location/Obsevations  should be blank
Next i


End Sub
 

Attachments

#2 ·
hi


try this variation;


Sub REMOVE()

Dim p As Long
p = Cells(Rows.Count, "a").End(xlUp).Row

For i = 1 To p
If InStr(1, Range("k" & i), "None") > 0 Then
Range("L" & i) = ""
Range("M" & i) = ""
End If
'If no Issue, Location/Obsevations should be blank
Next i

End Sub
 
#3 ·
Thanks for the suggestion; howeve, the word 'None' appears to not be recognized. I had to use the offset function to make it work properly. I don' tknow why, but this works.. Thanks again for your assistance.

Code:
Range("k2").Select
        For i = 2 To p
             If Selection.Value = "None" Then
        Selection.Offset(0, 1).Select       'Move to next column
        Selection.Value = ""                'Remove info
        Selection.Offset(0, 1).Select      'Move to next column
        Selection.Value = ""                'Remove info
        Selection.Offset(0, 1).Select       'Move to next column
        Selection.Value = " "               'Remove info'
        Selection.Offset(1, -3).Select      'Go to Next Record's Issue Type Column (down 1 row, back 3 columns) and select it
        Else
        Selection.Offset(1, 0).Select       'If "None" is not found, go down to the next record and select it
        End If
       Next i
 
Status
Not open for further replies.
You have insufficient privileges to reply here.
Top