Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
nickystan
 
Posts: n/a
Default Run a macro if a certain value is entered in a cell

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.
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Dave Peterson
 
Posts: n/a
Default Run a macro if a certain value is entered in a cell

You can use a worksheet event ...

Option Explicit

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count 1 Then Exit Sub
If Intersect(Target, Me.Range("a1")) Is Nothing Then Exit Sub
If Target.Value = "" Then Exit Sub

MsgBox "You just changed: " & Target.Address(0, 0) & vbLf & _
". Now don't forget to..."

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:

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.


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
nickystan
 
Posts: n/a
Default Run a macro if a certain value is entered in a cell

Thanks - that was really helpful

"Dave Peterson" wrote:

You can use a worksheet event ...

Option Explicit

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count 1 Then Exit Sub
If Intersect(Target, Me.Range("a1")) Is Nothing Then Exit Sub
If Target.Value = "" Then Exit Sub

MsgBox "You just changed: " & Target.Address(0, 0) & vbLf & _
". Now don't forget to..."

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:

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.


--

Dave Peterson

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Keyboard Macro Just Copies Content of Previous Cell Andy Excel Discussion (Misc queries) 1 October 24th 05 11:54 PM
Macro help - copy a cell down gjcase Excel Discussion (Misc queries) 3 September 4th 05 05:09 AM
macro help thephoenix12 Excel Discussion (Misc queries) 4 July 15th 05 05:57 PM
Copy cell format to cell on another worksht and update automatical kevinm Excel Worksheet Functions 21 May 19th 05 11:07 AM
GET.CELL Biff Excel Worksheet Functions 2 November 24th 04 07:16 PM


All times are GMT +1. The time now is 07:25 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"