+ Reply to Thread
Results 1 to 5 of 5

Thread: Preserve conditional formatting when copying cells from one sheet to another

  1. #1
    Registered User
    Join Date
    07-13-2010
    Location
    NYC, NY
    MS-Off Ver
    Excel 2007
    Posts
    5

    Preserve conditional formatting when copying cells from one sheet to another

    Hi,

    In my three sheet workbook, the second and third sheet contain project statuses ('Live and Completed') and the main sheet grabs all the projects that are currently "Live", when i hit the "Update" button.

    The second and third sheet also contain the 'planned' start and end dates of a project and the 'actual' start and end date of the project, (shown as dates and as a gantt chart). Conditional formatting is applied here (green bars for live projects and red ones for completed projects)

    Now conditional formatting works well on these two sheets but when i try to copy all the Live rows into the main sheet, the rows without 'actual' start and end dates goes bonkers (it shades the entire row).

    Is it possible to preserve the formatting just as it was in the sub sheets?

    And i got the code to copy the rows somewhere on the net and its very slow when i have more than 20 rows. Is it possible to optimize the code as well??

    Please look into the attached sheet, so that you can understand my problem better.

    Thanks in advance for all the help.
    Attached Files Attached Files
    Last edited by nojamindonut; 07-15-2010 at 08:44 AM.

  2. #2
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    Apparently I can't say
    MS-Off Ver
    Apparently I can't say
    Posts
    8,274

    Re: Preserve conditional formatting when copying cells from one sheet to another

    You need to make sure the data starts in the same rows on all sheets (since the CF rules look at row 2 for the dates), so either insert some rows in the detail sheets or delete the rows at the top of the summary sheet.

  3. #3
    Registered User
    Join Date
    07-13-2010
    Location
    NYC, NY
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Preserve conditional formatting when copying cells from one sheet to another

    Thanks for the reply. I inserted a couple of rows to my other two sheets, i can now see the 'Planned' formats but i still see the dark green format applied to the entire row.

    This is the code that i use to copy the rows to my main sheet.

    Sub PickRows1()
        Dim Source As Worksheet
        Dim Dest As Worksheet
        Dim WatchCol As Range
        Dim cel As Range
        Dim WatchFor
    
        Set Source = ThisWorkbook.Worksheets("Analyst 1")
        Set Dest = ThisWorkbook.Worksheets("Summary")
        Set WatchCol = Source.Range("I4:I1000")
        WatchFor = "Live"
        Range("a7:i50").ClearContents
        For Each cel In Intersect(Source.UsedRange, WatchCol).Cells    
            If cel = WatchFor Then
                cel.EntireRow.Copy Destination:=Dest.Range("A1000").End(xlUp).Offset(1, 0)
            End If
        Next  
    End Sub

    Can this code be modified to pick the first nine cells of every row (from Analyst 1 and Analyst 2 sheets) instead of the entire row and then apply conditional formatting?
    Attached Files Attached Files
    Last edited by nojamindonut; 07-15-2010 at 08:11 AM.

  4. #4
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    Apparently I can't say
    MS-Off Ver
    Apparently I can't say
    Posts
    8,274

    Re: Preserve conditional formatting when copying cells from one sheet to another

    Change the Copy line to:
    Source.Cells(cel.Row, "A").Resize(, 9).Copy Destination:=Dest.Range("A1000").End(xlUp).Offset(1, 0)

  5. #5
    Registered User
    Join Date
    07-13-2010
    Location
    NYC, NY
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Preserve conditional formatting when copying cells from one sheet to another

    Thank you, it works great!!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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.2.0