Hi,
I want to have it so that on a column if a certain value is entered in any
of the cells then a message is displayed to tell them to do something else.
I want to be able to run a macro if the value is entered.
You can use a worksheet event ...
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count gt; 1 Then Exit Sub
If Intersect(Target, Me.Range(quot;a1quot;)) Is Nothing Then Exit Sub
If Target.Value = quot;quot; Then Exit Sub
MsgBox quot;You just changed: quot; amp; Target.Address(0, 0) amp; vbLf amp; _
quot;. Now don't forget to...quot;
End Sub
Right click on the worksheet tab that should have this behavior. Select view
code and paste this into the code window that just opened.
Change A1 to the address of the cell you want to check.
nickystan wrote:
gt;
gt; Hi,
gt; I want to have it so that on a column if a certain value is entered in any
gt; of the cells then a message is displayed to tell them to do something else.
gt; I want to be able to run a macro if the value is entered.
--
Dave Peterson
Thanks - that was really helpful
quot;Dave Petersonquot; wrote:
gt; You can use a worksheet event ...
gt;
gt; Option Explicit
gt;
gt; Private Sub Worksheet_Change(ByVal Target As Range)
gt; If Target.Cells.Count gt; 1 Then Exit Sub
gt; If Intersect(Target, Me.Range(quot;a1quot;)) Is Nothing Then Exit Sub
gt; If Target.Value = quot;quot; Then Exit Sub
gt;
gt; MsgBox quot;You just changed: quot; amp; Target.Address(0, 0) amp; vbLf amp; _
gt; quot;. Now don't forget to...quot;
gt;
gt; End Sub
gt;
gt; Right click on the worksheet tab that should have this behavior. Select view
gt; code and paste this into the code window that just opened.
gt;
gt; Change A1 to the address of the cell you want to check.
gt;
gt; nickystan wrote:
gt; gt;
gt; gt; Hi,
gt; gt; I want to have it so that on a column if a certain value is entered in any
gt; gt; of the cells then a message is displayed to tell them to do something else.
gt; gt; I want to be able to run a macro if the value is entered.
gt;
gt; --
gt;
gt; Dave Peterson
gt;
- Jul 20 Thu 2006 20:08
Run a macro if a certain value is entered in a cell
close
全站熱搜
留言列表
發表留言