+ Reply to Thread
Results 1 to 6 of 6

what Event is triggered when user adds/deletes rows?

  1. #1
    Forum Contributor
    Join Date
    08-09-2005
    MS-Off Ver
    2003 & 2007
    Posts
    111

    what Event is triggered when user adds/deletes rows?

    I'm trying to create VBA conditional formatting (more than 4 formats needed).

    One of my formats involves alternating row colors, e.g.:

    Please Login or Register  to view this content.
    If the user inserts or deletes rows, then I'll have to update everything below the change. For which Worksheet Event should I be writing code and what range will it pass to my subroutine so that I know where to work the changes?

  2. #2
    Registered User
    Join Date
    12-19-2007
    Posts
    10
    Try the worksheet change event.

    The range should be the
    Please Login or Register  to view this content.
    Last edited by VBA Noob; 12-20-2007 at 05:57 PM.

  3. #3
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689
    Unless you're using Excel 2007, Excel will map whatever RGB color you specify to the nearest color on the 56-color palette. Use instead,
    Please Login or Register  to view this content.

  4. #4
    Forum Contributor
    Join Date
    08-09-2005
    MS-Off Ver
    2003 & 2007
    Posts
    111
    Let me make sure I understand you. If the user deletes a row, the Worksheet_Change Event will pass me the first non-deleted row below that, correct?

    Then is there any way for a Worksheet_Chage subroutine to tell that a row was deleted? I mean, how can my code distinguish the deleted-row case from a case where the user pasted over all the values in a given row?

    ps. thanks for the RGB tip. Is there a quick way to tell which ColorIndex goes to which color? I mean besides writing code to test each one.

  5. #5
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689
    Here -- you can make a wall chart suitable for hanging ...
    Attached Files Attached Files

  6. #6
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689
    Put this in the Worksheet module; it checks for deleted rows, columns, and random ranges. Skip the cases you don't want, and add whatever processing you want in lieu of what's there.
    Please Login or Register  to view this content.

+ 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