+ Reply to Thread
Results 1 to 3 of 3

Stuck in a loop

  1. #1
    CWillis
    Guest

    Stuck in a loop

    I am using a drop down menu. When an item from the drop down menu is
    selected, certain cells are formatted differently. This is done immediately
    using:

    Private Sub Worksheet_Change(ByVal Target As Range)

    Each selection is sent into a seperate sub which first clears any current
    formatting and then formats the cells. The problem is that this unformatting
    and then formatting continues until I have to hit "esc." Is there a way to
    run it only once per selection of the drop down box? Thanks!

  2. #2
    Chip Pearson
    Guest

    Re: Stuck in a loop

    You probably need to disable events while your code runs. E.g,

    Private Sub Worksheet_Change(ByVal Target As Range)
    Application.EnableEvents = False
    '
    ' your code here
    '
    Application.EnableEvents = True
    End Sub


    --
    Cordially,
    Chip Pearson
    Microsoft MVP - Excel
    Pearson Software Consulting, LLC
    www.cpearson.com



    "CWillis" <[email protected]> wrote in message
    news:[email protected]...
    >I am using a drop down menu. When an item from the drop down
    >menu is
    > selected, certain cells are formatted differently. This is
    > done immediately
    > using:
    >
    > Private Sub Worksheet_Change(ByVal Target As Range)
    >
    > Each selection is sent into a seperate sub which first clears
    > any current
    > formatting and then formats the cells. The problem is that
    > this unformatting
    > and then formatting continues until I have to hit "esc." Is
    > there a way to
    > run it only once per selection of the drop down box? Thanks!




  3. #3
    CWillis
    Guest

    Re: Stuck in a loop

    Works great! Thanks Chip.

    "Chip Pearson" wrote:

    > You probably need to disable events while your code runs. E.g,
    >
    > Private Sub Worksheet_Change(ByVal Target As Range)
    > Application.EnableEvents = False
    > '
    > ' your code here
    > '
    > Application.EnableEvents = True
    > End Sub
    >
    >
    > --
    > Cordially,
    > Chip Pearson
    > Microsoft MVP - Excel
    > Pearson Software Consulting, LLC
    > www.cpearson.com
    >
    >
    >
    > "CWillis" <[email protected]> wrote in message
    > news:[email protected]...
    > >I am using a drop down menu. When an item from the drop down
    > >menu is
    > > selected, certain cells are formatted differently. This is
    > > done immediately
    > > using:
    > >
    > > Private Sub Worksheet_Change(ByVal Target As Range)
    > >
    > > Each selection is sent into a seperate sub which first clears
    > > any current
    > > formatting and then formats the cells. The problem is that
    > > this unformatting
    > > and then formatting continues until I have to hit "esc." Is
    > > there a way to
    > > run it only once per selection of the drop down box? Thanks!

    >
    >
    >


+ 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