#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 194
Default Change event Macro

I have recorded a macro that I currently run via Tools/Macro/Macros/Run. It
works fine but it is cumbersome to go throught that process. I could run it
on a toolbar button but what I really need is for it to run when a certain
word "Airport RV" is entered into a specific cell on a data entry sheet. This
cell G7:G26 is used to enter data that is moved to a specific sheet via a
vlookup formula. I have concluded that a Change Event is probibly the way to
go to activate this macro, but I have no skills to make the connection. Any
help would be appreciated.

Mike Rogers
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,203
Default Change event Macro

I believe this will probably help you out:

Private Sub Worksheet_Change(ByVal Target As Range)
Dim iSect As Range

Set iSect = Application.Intersect(Range(Target.Address), Range("G7:G26"))
If iSect Is Nothing Then
Exit Sub '
End If
Application.EnableEvents = False
If UCase(Trim(Target.Value)) = "AIRPORT RV" Then
'your existing macro code here
End If
Application.EnableEvents = True
End Sub

note that it goes into the Worksheet's _Change() event. Change "G7:G26" to
the exact addresses where you want to look for "Airport RV" to be entered.
That way it won't eat up too much time checking every time you change
something on the sheet - the Application.Intersect will prevent even the test
from being executed unless a change has been made in one of those cells. The
UCase(Trim(Target.Value)) strips off leading and trailing white space and
converts to all uppercase for comparison, so it is case insensitive.

"Mike Rogers" wrote:

I have recorded a macro that I currently run via Tools/Macro/Macros/Run. It
works fine but it is cumbersome to go throught that process. I could run it
on a toolbar button but what I really need is for it to run when a certain
word "Airport RV" is entered into a specific cell on a data entry sheet. This
cell G7:G26 is used to enter data that is moved to a specific sheet via a
vlookup formula. I have concluded that a Change Event is probibly the way to
go to activate this macro, but I have no skills to make the connection. Any
help would be appreciated.

Mike Rogers

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
error when running cut & paste macro Otto Moehrbach Excel Worksheet Functions 4 August 9th 06 01:49 PM
Macro To Change Cell Color When Value Changes carl Excel Worksheet Functions 4 March 14th 06 08:24 PM
Macro broken with workbook name change Annabelle Excel Discussion (Misc queries) 2 February 3rd 06 12:48 AM
event macro on a condition TUNGANA KURMA RAJU Excel Discussion (Misc queries) 2 December 19th 05 07:15 AM
how do i change the expense statement template macro Mad2691 Excel Worksheet Functions 1 January 28th 05 01:21 PM


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

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"