+ Reply to Thread
Results 1 to 3 of 3

Problem with Conditional Formatting when Inserting a Row

  1. #1
    JGeniti
    Guest

    Problem with Conditional Formatting when Inserting a Row

    I currently have a procedure that allows the users to click on a button
    to move a selected row up or down in a list. The problem I'm having is
    that when they move the rows down the conditional formating on the
    cells get screwed up. Below is an example of what happens when I try to
    move row 1 down to row 2.

    Conditional Formatting Formulas Prior to Move.
    (There is actually 2 conditions in each, but for simplicty I just used
    1).
    Row 1 = "=$A1"
    Row 2 = "=$A2"
    Row 3 = "=$A3"

    Conditional Formatting After I moved row one down to row 2.

    Row 1 = Formatting is gone
    Row 2 = "=$A4"
    Row 3 = "=$A5"

    Here is the part of the code that I use to move the rows. The problem
    seems to occur when I use the insert statement.

    MoveFrom = Selection.Row
    Rows(MoveFrom).Select
    Selection.Cut
    Rows(MoveFrom + 2).Select
    Selection.Insert shift:=xlDown
    Rows(MoveFrom + 1).Select

    The thing that makes this more frustrating is that I don't get the same
    problem when the user moves a row up. It's basically the same logic.
    Any help would be greatlty appreciated.

    Thanks,
    James


  2. #2
    Bob Phillips
    Guest

    Re: Problem with Conditional Formatting when Inserting a Row

    How about copying?

    movefrom = Selection.Row
    Rows(movefrom).Copy
    Rows(movefrom + 2).Insert shift:=xlDown
    Rows(movefrom + 1).Select

    --

    HTH

    RP
    (remove nothere from the email address if mailing direct)


    "JGeniti" <[email protected]> wrote in message
    news:[email protected]...
    > I currently have a procedure that allows the users to click on a button
    > to move a selected row up or down in a list. The problem I'm having is
    > that when they move the rows down the conditional formating on the
    > cells get screwed up. Below is an example of what happens when I try to
    > move row 1 down to row 2.
    >
    > Conditional Formatting Formulas Prior to Move.
    > (There is actually 2 conditions in each, but for simplicty I just used
    > 1).
    > Row 1 = "=$A1"
    > Row 2 = "=$A2"
    > Row 3 = "=$A3"
    >
    > Conditional Formatting After I moved row one down to row 2.
    >
    > Row 1 = Formatting is gone
    > Row 2 = "=$A4"
    > Row 3 = "=$A5"
    >
    > Here is the part of the code that I use to move the rows. The problem
    > seems to occur when I use the insert statement.
    >
    > MoveFrom = Selection.Row
    > Rows(MoveFrom).Select
    > Selection.Cut
    > Rows(MoveFrom + 2).Select
    > Selection.Insert shift:=xlDown
    > Rows(MoveFrom + 1).Select
    >
    > The thing that makes this more frustrating is that I don't get the same
    > problem when the user moves a row up. It's basically the same logic.
    > Any help would be greatlty appreciated.
    >
    > Thanks,
    > James
    >




  3. #3
    JGeniti
    Guest

    Re: Problem with Conditional Formatting when Inserting a Row

    Thanks Bob,
    Actually that's what I wound up doing to get it to work. I also had to
    add a line of code to go up and delete the original line because I used
    the copy instead of cut. I'm guessing that there is some sort of glich
    with Cut commnand because it seems to over adjust the row references
    when you use the insert statement.

    Thanks again,
    James


+ 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