Results 1 to 10 of 10

Thread: Migrate Or Copy Columns Depending On Their Color Based On Conditional Formatting

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Junior Member
    Join Date
    Mar 2014
    Posts
    27
    Rep Power
    0

    Question Migrate Or Copy Columns Depending On Their Color Based On Conditional Formatting

    You can migrate rows dependent on the color of the column and the color depends on "conditional formatting"
    Attached Files Attached Files

  2. #2
    Moderator
    Join Date
    Jul 2012
    Posts
    156
    Rep Power
    13
    Determining color of CF in code is always tricky. It's better to evaluate the CF-formula in your code and based on that migrate your data.

    https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA
    https://eileenslounge.com/viewtopic.php?p=244184#p244184
    https://eileenslounge.com/viewtopic.php?p=246586#p246586
    https://eileenslounge.com/viewtopic.php?p=246112#p246112
    https://eileenslounge.com/viewtopic.php?p=246112#p246112
    https://eileenslounge.com/viewtopic.php?p=245761#p245761
    https://eileenslounge.com/viewtopic.php?p=245722#p245722
    https://eileenslounge.com/viewtopic.php?p=245616#p245616
    https://eileenslounge.com/viewtopic.php?p=247043#p247043
    https://www.excelfox.com/forum/showthread.php/2307-VBA-Range-Sort-with-arrays-Alternative-for-simple-use
    https://eileenslounge.com/viewtopic.php?p=245238#p245238
    https://eileenslounge.com/viewtopic.php?p=245131#p245131
    https://eileenslounge.com/viewtopic.php?f=18&t=31638
    https://eileenslounge.com/viewtopic.php?p=244579#p244579
    https://eileenslounge.com/viewtopic.php?p=244648#p244648
    https://eileenslounge.com/viewtopic.php?p=244647#p244647
    https://eileenslounge.com/viewtopic.php?p=244577#p244577
    https://eileenslounge.com/viewtopic.php?p=245201#p245201
    https://eileenslounge.com/viewtopic.php?p=243975#p243975
    https://eileenslounge.com/viewtopic.php?p=243884#p243884
    https://eileenslounge.com/viewtopic.php?p=242439#p242439
    https://eileenslounge.com/viewtopic.php?p=243595#p243595
    https://eileenslounge.com/viewtopic.php?p=243589#p243589
    https://eileenslounge.com/viewtopic.php?p=243589#p243589
    https://eileenslounge.com/viewtopic.php?p=243002#p243002
    https://www.eileenslounge.com/viewtopic.php?p=242761#p242761
    https://eileenslounge.com/viewtopic.php?p=242459#p242459
    https://eileenslounge.com/viewtopic.php?p=242054#p242054
    https://eileenslounge.com/viewtopic.php?p=241404#p241404
    https://eileenslounge.com/viewtopic.php?p=229145#p229145
    https://eileenslounge.com/viewtopic.php?p=228710#p228710
    https://eileenslounge.com/viewtopic.php?p=226938#p226938
    https://eileenslounge.com/viewtopic.php?f=18&t=28885
    https://eileenslounge.com/viewtopic.php?p=222689#p222689
    https://eileenslounge.com/viewtopic.php?p=221622#p221622
    https://eileenslounge.com/viewtopic.php?f=27&t=22512
    https://eileenslounge.com/viewtopic.php?f=26&t=26183
    https://eileenslounge.com/viewtopic.php?f=26&t=26030
    https://eileenslounge.com/viewtopic.php?p=202322#p202322
    https://www.excelforum.com/word-formatting-and-general/1174522-finding-a-particular-word-phrase-in-word.html#post4604396
    https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA
    Last edited by DocAElstein; 04-16-2024 at 06:41 PM.

  3. #3
    Member p45cal's Avatar
    Join Date
    Oct 2013
    Posts
    94
    Rep Power
    12
    There is no conditional formatting in your file.

  4. #4
    Junior Member
    Join Date
    Mar 2014
    Posts
    27
    Rep Power
    0
    This file contains an example of conditional formatting
    Attached Files Attached Files

  5. #5
    Moderator
    Join Date
    Jul 2012
    Posts
    156
    Rep Power
    13
    Code:
    Sub tst()
        For Each cl In Sheets("Sheet1").Columns(1).SpecialCells(2)
            Sheets("Sheet2").Range("B" & Rows.Count).End(xlUp).Offset(1).Resize(, 5) = cl.Offset(, 1).Resize(, 5).Value
        Next
    End Sub
    The above code copies the result to Sheet2

  6. #6
    Member p45cal's Avatar
    Join Date
    Oct 2013
    Posts
    94
    Rep Power
    12
    Are you looking to do this with a macro?
    Confirm you have Excel 2003 and no higher.
    Is the colour of the conditional format always because of a single formula (or can several different formulae lead to the same colour)?

  7. #7
    Junior Member
    Join Date
    Mar 2014
    Posts
    27
    Rep Power
    0
    Yes looking for code migrates table by "conditional formatting"
    I use Office 2003

  8. #8
    Junior Member
    Join Date
    Mar 2014
    Posts
    27
    Rep Power
    0
    Give me an error code
    " RUN-TIME ERROR "1004 "

  9. #9
    Moderator
    Join Date
    Jul 2012
    Posts
    156
    Rep Power
    13
    In your example file from Post#4 this works just fine for me so something must be different in your original file.

  10. #10
    Member p45cal's Avatar
    Join Date
    Oct 2013
    Posts
    94
    Rep Power
    12
    Quote Originally Posted by bakerman View Post
    In your example file from Post#4 this works just fine for me so something must be different in your original file.
    I'd guess emmye998 either has no constants in column A, or formulae.
    So the file probably isn't representative of what he has.
    I didn't get an answer to one of my questions:
    Is the colour of the conditional format always because of a single formula (or can several different formulae lead to the same colour)?

    So we need a representative file.
    Conditional formatting in Excel 2003 is more basic and there isn't a cell's .DisplayFormat.Interior.Color until Excel 2010.
    So finding whether a cell's conditional format is returning a given color to the cell can be complex in Excel 2003.

    Normally, in code, I'd autofilter the range on a column or columns, copy and paste to another location, then remove the filter. However if may be more complex than that with emmye998's file since there may be more than one conditional format formula returning the same colour, hence my question. It may be easier to add helper column(s), hidden if you want, filter on them and then copy/paste.

Similar Threads

  1. Get Displayed Cell Color (whether from Conditional Formatting or not)
    By Rick Rothstein in forum Rick Rothstein's Corner
    Replies: 14
    Last Post: 10-21-2013, 07:11 PM
  2. get conditional formatting color of a cell
    By SP69 in forum Excel Help
    Replies: 2
    Last Post: 09-30-2013, 03:08 PM
  3. Replies: 4
    Last Post: 07-04-2013, 01:56 PM
  4. Conditional formatting
    By mahmoud-lee in forum Excel Help
    Replies: 9
    Last Post: 05-30-2013, 03:00 PM
  5. Replies: 2
    Last Post: 09-16-2012, 02:28 AM

Posting Permissions

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