![]() |
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 |
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 |
All times are GMT +1. The time now is 11:55 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com