Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Running a macro based on a value

Is there a way to create an "event based" macro in Excel? I need to have an
input box pop up whenever a cell value greater than 0 is entered.
Thanks!

--


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Running a macro based on a value

Use the Change event if it will be entered manually

see Chip Pearson's overview of events
http://www.cpearson.com/excel/events.htm

--
Regards,
Tom Ogilvy


"Jeanne Conroy" wrote:

Is there a way to create an "event based" macro in Excel? I need to have an
input box pop up whenever a cell value greater than 0 is entered.
Thanks!

--



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 32
Default Running a macro based on a value

the only way i can think of to do this is to have it run from the sheet
code (right click select view code)

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

If cell(x,y).Value 0 Then
macroname
End if

end sub

put that in a loop and that should work.

  #4   Report Post  
Posted to microsoft.public.excel.programming
ron ron is offline
external usenet poster
 
Posts: 118
Default Running a macro based on a value

An appropriately modified version of the following code should do
it...Ron

OnEntry Property and Change Event
An OnEntry handler runs when the user enters data in a worksheet. You
can use the OnEntry property of either the Worksheet or Application
object to associate a procedure with the entry of data on any
worksheet. The event occurs after the user enters data in a cell and
presses ENTER or selects another cell. The event does not occur if the
user click Cut or Paste on the Edit menu or if another procedure
changes the contents of a cell.

For example, the following code associates a procedure that validates
the data entered in a cell with the OnEntry event only if the cell is
in column B:


Sub TrapEntry()
Workbooks("GeneData").Worksheet("GeneCountDB").OnE ntry = _
"ValidateColB"
End Sub
Sub ValidateColB()
With ActiveCell
If .Column = 2 Then ' Test for second column.
If IsNumeric(.Value) Then
If .Value < 0 or .Value 255 Then
Msgbox "Entry must be between 0 and 255."
.Value = ""
End If
Else
' Handle nonnumeric entry.
Msgbox "Entry must be a number between 0 and 255."
.Value = ""
End If
End If
End With
End Sub

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
Running a macro based on the time WNYC Excel Discussion (Misc queries) 1 March 22nd 10 09:45 PM
Finding a value based on a running sum John Casey Excel Worksheet Functions 4 April 14th 08 05:56 PM
running total based on text ucastores Excel Discussion (Misc queries) 8 November 28th 07 09:16 PM
Running a macro based on a cells value Piwo Excel Programming 4 April 18th 05 08:28 PM
Running a query based off values in col A sjones Excel Programming 1 June 28th 04 02:37 PM


All times are GMT +1. The time now is 12:47 PM.

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

About Us

"It's about Microsoft Excel"