+ Reply to Thread
Results 1 to 9 of 9

Comparing Value

Hybrid View

  1. #1
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,655

    Re: Comparing Value

    Try this code to see if this works as per your requirement.
    Sub comparevalues()
    Dim rng As Range, cell As Range, rng1 As Range, cell1 As Range
    Dim lr As Long, lc As Integer
    lr = Cells(Rows.Count, 1).End(xlUp).Row
    lc = Cells(1, Columns.Count).End(xlToLeft).Column
    Set rng1 = Range(Cells(1, 5), Cells(1, lc))
    Application.ScreenUpdating = False
    For Each cell1 In rng1
        Set rng = Range(Cells(2, cell1.Column), Cells(lr, cell1.Column))
        For Each cell In rng
        If cell <> "" Then
            If cell > cell.Offset(0, -4) * 0.05 Then
                cell.Interior.ColorIndex = 3
            End If
            If cell < cell.Offset(0, -4) * 0.05 Then
                cell.Interior.ColorIndex = 6
            End If
        End If
        Next cell
    Next cell1
    Application.ScreenUpdating = True
    End Sub
    Regards
    sktneer


    Treat people the way you want to be treated. Talk to people the way you want to be talked to.
    Respect is earned NOT given.

  2. #2
    Forum Contributor
    Join Date
    02-19-2014
    Location
    NJ
    MS-Off Ver
    Excel 2010
    Posts
    308

    Re: Comparing Value

    Hi Sktneer,

    Thats awesome..It is working fine.One more query.If i have more number of sheet which having what should i do?..I have tried and it is working for the current sheet.Pls find the attached sheet for you reference....
    Attached Files Attached Files

+ 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. Comparing
    By welchs101 in forum Excel General
    Replies: 5
    Last Post: 07-03-2012, 07:24 PM
  2. Comparing two columns
    By rg1210 in forum Excel General
    Replies: 2
    Last Post: 10-27-2011, 11:59 PM
  3. comparing-What I wish to do
    By kchris in forum Excel General
    Replies: 2
    Last Post: 02-28-2007, 03:03 PM
  4. comparing
    By popop in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 12-13-2006, 08:34 AM
  5. Comparing two spreadsheets
    By Morten in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 10-21-2005, 09:30 AM

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