+ Reply to Thread
Results 1 to 10 of 10

Compare two ranges using the fill color changes

  1. #1
    Registered User
    Join Date
    03-16-2012
    Location
    Russia
    MS-Off Ver
    Excel 2010
    Posts
    98

    Compare two ranges using the fill color changes

    1. Range(E6:G) and filled to the last row in any color (color shading not interrupted) - basic control data
    2. Range(L6:N) and filled to the last row in any color (color shading not interrupted) - new values
    3. There is a continuous column D - on the basis of it is filled with the color of the entire table. That is, we can focus on a single column, the last line defining two ranges, or a condition - that the two bands, old and new - have a continuous fill color to the last row.
    4. If the range of point 2 is unlike matching point range cells point 1 - is to allocate it any color

    Help pls with macro (not with conditional formatting). I can do that with smart table and conditional formatting, but needs macro.
    Visual example - what i need - is in attach.
    Attached Files Attached Files

  2. #2
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Compare two ranges using the fill color changes

    I don't understand your explanation but a macro to change the fill color is very simple:

    Please Login or Register  to view this content.
    You can also use RGB
    Please Login or Register  to view this content.
    You can apply it to a Range as well
    Please Login or Register  to view this content.
    Hope this helps to put you on the right track

    BTW: its fun to see Book1 in Cyrrillic Kniga1
    ---
    Hans
    "IT" Always crosses your path!
    May the (vba) code be with you... if it isn't; start debugging!
    If you like my answer, Click the * below to say thank-you

  3. #3
    Registered User
    Join Date
    03-16-2012
    Location
    Russia
    MS-Off Ver
    Excel 2010
    Posts
    98

    Re: Compare two ranges using the fill color changes

    Look the 2nd example pls. I do what i need by conditional formatting and smart table.
    That formulas =($D6<>"")*(L6<>E6) for =$L$6:$N$31

    But need macro instead of this example (need to avoid conditional formatting and smart table).
    Need compare Range (E6:G) till last row with Range(L6:N) till last row. And if cells in 2nd range <> cells values in first range - then fill them any color.
    Attached Files Attached Files

  4. #4
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Compare two ranges using the fill color changes

    I don't quite see what your conditional formatting does, but I did add a macro and removed the conditional
    [cdoe]
    Public Sub CheckRange()
    Dim cell As Range
    Dim xRow As Long
    Dim lstRow As Long
    For Each cell In Range("L6:N31")
    cell.Interior.Color = RGB(146, 208, 80)
    If Cells(cell.Row, "D") <> "" And (Cells(cell.Row, "L") <> Cells(cell.Row, "E")) Then
    cell.Interior.Color = RGB(255, 102, 204)
    End If
    Next cell
    End Sub
    [/code]

    The macro will not run automatically but that you can do yourself with a worksheet event
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    03-16-2012
    Location
    Russia
    MS-Off Ver
    Excel 2010
    Posts
    98

    Re: Compare two ranges using the fill color changes

    Fine, but works for one pair columns and for fixed range only. And fill whole row, not only one cell.

    But need compare columns: L with E, M with F, N with G.
    And in case cell value in column L<> the same cell adress in column E then fill by color only one cell in L
    Next for M and N columns.

    And need it to for dynamic columns like from L6 to last row in L
    Last rowfound like that Range("L6" & Rows.Count).End(3).Row

    But no enough knowledges to expand your macro on my case Excuse my Eng pls..
    Last edited by Remphan; 06-07-2016 at 05:23 PM.

  6. #6
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Compare two ranges using the fill color changes

    No problme, English is fine, my Russian is worse
    Then I think it is time you start to learn
    You have the macro so try and practice.
    It is bedtime here. I'll see if I can do more tomorrow.
    The macro works for all rows between 6 and 31. Will there be more rows?

  7. #7
    Registered User
    Join Date
    03-16-2012
    Location
    Russia
    MS-Off Ver
    Excel 2010
    Posts
    98

    Re: Compare two ranges using the fill color changes

    Yes, the number of rows is a very dynamic value. from 6 row till last filled. Thank you.

  8. #8
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Compare two ranges using the fill color changes

    This works now and if the table is expanded it will still work
    Attached Files Attached Files

  9. #9
    Registered User
    Join Date
    03-16-2012
    Location
    Russia
    MS-Off Ver
    Excel 2010
    Posts
    98

    Re: Compare two ranges using the fill color changes

    Your macro works well

    I found more little macro, but its not work automatically for L,M,N columns (on every chanlls. Only, when manyally enter values...
    Can anybody correct it?

    Please Login or Register  to view this content.
    Attached Files Attached Files

  10. #10
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Compare two ranges using the fill color changes

    Check my way of doing it.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] How to fill color cells based on another cell's fill color?
    By putritersenyum in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 05-22-2016, 08:58 AM
  2. [SOLVED] Click oval option button to fill/unfill color, also change border color to match fill
    By Rocky2013 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-07-2015, 08:29 PM
  3. How to color-fill blank cells, then once data is entered cell is no-fill
    By hatemail13 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 03-28-2013, 07:57 PM
  4. [SOLVED] Compare Worksheets: Transcribe adjorning cells and Insert value based on Fill Color
    By ub3rm0nk3y in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-25-2013, 07:18 PM
  5. [SOLVED]Fill Color (highlight cells) but not to print fill color
    By itszille in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-24-2012, 05:37 PM
  6. Compare 2 worksheets, delete dupes and group by back fill color using macro
    By jousterlj in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-25-2011, 01:50 PM
  7. Replies: 0
    Last Post: 04-06-2009, 04:07 PM

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