Consulting

Results 1 to 18 of 18

Thread: Compare same number in sheet1 and sheet2

  1. #1

    Compare same number in sheet1 and sheet2

    Hi all,

    I would like to seek help for comparing the number in sheet1 whether available in sheet2. If sheet1 got the number in sheet2, it will highlight in sheet1 .Please refer my attachment. Thanks. hope to hear from you soon.

  2. #2
    See attached. USed Named range and Conditional formatting.

  3. #3
    Hi,

    I not understand used name range and conditional format? Can u please explain. Thanks

  4. #4
    Select cells B6 to B10 and look at name box (leftmost dropdown list type, where normally cell address is shown) in the Original Data sheet. "list" name will appear
    Go to next sheet and select B2, then Format\Conditional formatting, you will see the formula.

  5. #5
    Hi,

    How about i want to do coding for comparing same number? Can u show me?
    I want to click the button and it's start comparing the same number between 2 sheet. Thanks
    Last edited by apple; 08-04-2007 at 12:37 AM.

  6. #6
    Try this:
    -------------------------------------------------
    The more details you give, the easier it is to understand your question. Don't save the effort, tell us twice rather than not at all. The amount of info you give strongly influences the quality of answer, and also how fast you get it.

  7. #7
    Hi Jimmy,

    Thanks for your help. Have a nice day. Cheers

  8. #8
    Hi Jimmy,

    Please do explain the code in red font.

    For Each c In Data.Cells
    Set Hit = plm.Find(c.Value, , xlValues, xlWhole, , , False)
    If Not Hit Is Nothing Then c.EntireRow.Interior.ColorIndex = 3
    Next
    End Sub


    Thanks. Hope you have a nice day.

  9. #9
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    It is looking for the value in the cell pointed to by the c variable within the range of cells pointed to by plm, and returning a range object, Hit, with the found cell.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  10. #10
    Hi,

    How about the comma in blue font between Set Hit = plm.Find(c.Value, , xlValues, xlWhole, , , False). What is the comma means?

  11. #11
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Just means it is skipping that value. Look at Find in VBA help.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  12. #12
    Hi,

    Can anyone help me as below question:

    Question 1:

    I want to highlight the number for 11 digit (XXXXX-XXXXX) in length as i highlighted in red colour. Please refer my attachment. Please teach me how to achieve that.Thanks
    Last edited by apple; 08-08-2007 at 06:09 AM.

  13. #13
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    [VBA] For Each c In Original_List.Cells
    Set Hit = Compare_List.Find(c.Value, , xlValues, xlWhole, , , False)
    If Not Hit Is Nothing Then
    Dim Test
    If InStr(1, Hit, "-") > 0 Then
    Test = Split(Hit, "-")
    If Len(Test(0)) = 5 And Len(Test(1)) = 5 Then
    c.Interior.ColorIndex = 3
    End If
    End If
    End If
    Next[/VBA]
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  14. #14
    Hi,

    Thanks for your help.

    Can you explain the syntax as below in red font:

    For Each c In Original_List.Cells
    Set Hit = Compare_List.Find(c.Value, , xlValues, xlWhole, , , False)
    If Not Hit Is Nothing Then
    Dim Test
    If InStr(1, Hit, "-") > 0 Then
    Test = Split(Hit, "-")
    If Len(Test(0)) = 5 And Len(Test(1)) = 5 Then
    c.Interior.ColorIndex = 3
    End If
    End If
    End If
    Next

  15. #15
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Dim Test

    declares a variable (wastefully as it does it every iteration of the loop)

    If InStr(1, Hit, "-") > 0 Then

    checks if the variable Hit contains a dash

    Test = Split(Hit, "-")

    and if so, it splits Hit into an array of values delimited by dash

    If Len(Test(0)) = 5 And Len(Test(1)) = 5 Then

    If the first or second item in that array is 5 characters
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  16. #16
    VBAX Master
    Joined
    Jun 2007
    Location
    East Sussex
    Posts
    1,110
    Location
    You could also just test if Instr(Hit, "-") = 6 and len(Hit) = 11
    Regards,
    Rory

    Microsoft MVP - Excel

  17. #17
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Quote Originally Posted by apple
    Can you explain the syntax as below in red font:
    Hi Apple
    You should check the Help file first and come back with any particular clarification you require.
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  18. #18
    Noted. Thanks

Posting Permissions

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