+ Reply to Thread
Results 1 to 2 of 2

Change event Macro

  1. #1
    Mike Rogers
    Guest

    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. #2
    JLatham
    Guest

    RE: 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 to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1