apply cell change event to single column - WorksheetChange Event
Private Sub Worksheet_Change(ByVal Target As Range)
Set t = Target
Set r = Range("N:N")
If Intersect(t, r) Is Nothing Then Exit Sub
Application.EnableEvents = False
If t.Value = "" Then
t.Offset(0, 1).Value = ""
Else
t.Offset(0, 1).Value = "Subfile"
End If
Application.EnableEvents = True
End Sub
--
Gary''s Student - gsnu2007h
" wrote:
dumbest question that will be posted all day, but here goes anyway.
How do I change the following macro so that it only applies to one
column instead of two? I don't know how to properly modify
Range(Cells(Target.Row, 15), Cells(Target.Row, 16)) to just one of
those columns. Deleting the second "range" gives me a run-time
error. Maybe I should be using something all together different
anyway. When the user enters a value into Column 14, I want the word
"Subfile" to appear in Column 15; however, if the user deletes the
text in Column 14, I want "Subfile" removed/deleted.
Any and all help is always appreciated.
Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
If Target.Column = 14 And Target.Value < "" Then
Range(Cells(Target.Row, 15), Cells(Target.Row, 16)).Value =
"Subfile"
End If
If Target.Column = 14 And Target.Value = "" Then
Range(Cells(Target.Row, 15), Cells(Target.Row, 16)).Value = ""
End If
Application.EnableEvents = True
End Sub
|