![]() |
macro restricted to one column
I have the following macro, but I would like to run only when a "w" is
entered in any cell in column A. Private Sub Worksheet_Change(ByVal Target As Range) If ActiveCell.Value = "w" Then Range("I" & ActiveCell.Row).Select End If End Sub Thanks in advance for the help!!! |
macro restricted to one column
In your Sheet module enter
Private Sub Worksheet_Change(ByVal Target As Range) If Not Application.Intersect(Range("A:A"), Target) Is Nothing Then If Target.Value = "w" Then Range("I" & Target.Row).Select End If End If End Sub "davemon" wrote: I have the following macro, but I would like to run only when a "w" is entered in any cell in column A. Private Sub Worksheet_Change(ByVal Target As Range) If ActiveCell.Value = "w" Then Range("I" & ActiveCell.Row).Select End If End Sub Thanks in advance for the help!!! |
macro restricted to one column
You need to change your if to the following condition:
If ActiveCell.Value = "w" And ActiveCell.Column = 1 Then but you will have to turn MOVE SELECTION AFTER ENTER to off by clicking TOOLS/OPTIONS, clicking the EDIT tab and turning off the checkbox. -- Kevin Backmann "davemon" wrote: I have the following macro, but I would like to run only when a "w" is entered in any cell in column A. Private Sub Worksheet_Change(ByVal Target As Range) If ActiveCell.Value = "w" Then Range("I" & ActiveCell.Row).Select End If End Sub Thanks in advance for the help!!! |
macro restricted to one column
Private Sub Worksheet_Change(ByVal Target As Range)
if target.cells.count 1 then exit sub 'only one cell at a time if intersect(target,me.range("a:a")) is nothing then exit sub if lcase(target.value) = "w" then me.cells(target.row,"I").select end if end sub davemon wrote: I have the following macro, but I would like to run only when a "w" is entered in any cell in column A. Private Sub Worksheet_Change(ByVal Target As Range) If ActiveCell.Value = "w" Then Range("I" & ActiveCell.Row).Select End If End Sub Thanks in advance for the help!!! -- Dave Peterson |
macro restricted to one column
Thanks again......... Works Great!!!!!!!!!!!
|
macro restricted to one column
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
'when entering data in a cell in Col A On Error GoTo enditall Application.EnableEvents = False If Target.Cells.Column = 1 Then n = Target.Row If Excel.Range("A" & n).Value = "w" Then Range("I" & n).Select End If End If enditall: Application.EnableEvents = True End Sub Gord Dibben MS Excel MVP On Thu, 21 Sep 2006 08:26:02 -0700, davemon wrote: I have the following macro, but I would like to run only when a "w" is entered in any cell in column A. Private Sub Worksheet_Change(ByVal Target As Range) If ActiveCell.Value = "w" Then Range("I" & ActiveCell.Row).Select End If End Sub Thanks in advance for the help!!! |
All times are GMT +1. The time now is 11:18 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com