Logo 
Search:

MS Office Forum

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds

Macro to clear cells

  Asked By: Joel    Date: Oct 11    Category: MS Office    Views: 1132
  

I need the VBA code for a macro that: If I type NA in column M the
values in J & K & N needs to be cleared in the same row. Hope this is
clear enough.

Share: 

 

1 Answer Found

 
Answer #1    Answered By: Leigh Carpenter     Answered On: Oct 11

Place the following in the worksheet code  module:

Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False

If Target.Count = 1 And Union(Target, Range("M:M")) _
.Address = Range("M:M").Address _
Then If Target.Value = "NA" Then Range("J" & Target _
.Row & ",K" & Target.Row & ",N" & Target.Row).Clear

Application.EnableEvents = True
End Sub


The block of 4 lines above is in reality one line with continuation
characters.

 
Didn't find what you were looking for? Find more on Macro to clear cells Or get search suggestion and latest updates.




Tagged: