+ Reply to Thread
Results 1 to 5 of 5

check whether column A match column B

Hybrid View

  1. #1
    Registered User
    Join Date
    11-18-2007
    Posts
    29

    check whether column A match column B

    pls help

    A
    apple
    orange
    banana
    pinapple
    japfruit
    kiwi
    etc

    B
    apple
    orange
    banana
    pinapple
    japfruit
    starfruit
    etc

    i need a macro or function that check whether column A5 is the same as column B5, if not the same bold or highlight yellow. in this example starfruit and kiwi will be bold bec not the same. thank

  2. #2
    Forum Contributor corinereyes's Avatar
    Join Date
    12-02-2003
    Location
    Philippines
    MS-Off Ver
    MS Excel 2016
    Posts
    520
    Hello,

    Say values are in cell A1 to B7

    try this code:

    Sub cHchangeF()
        Dim i As Integer
        For i = 1 To 7
            If Cells(i, 1).Value <> Cells(i, 2) Then
                Cells(i, 1).Font.Bold = True
                Cells(i, 2).Font.Bold = True
            End If
        Next i
    End Sub
    paste the code in a module in VBE (in your worksheet press ALT+F11) , in the insert menu (insert Module), the go back to the worksheet, Go Tools, Macro, select the macro named "cHchangeF" click run.
    Corine

  3. #3
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Or

    Sub Flag_Diff()
    Dim Lr As Long, i As Long
    Lr = Cells(Rows.Count, "A").End(xlUp).Row
    Application.ScreenUpdating = False
        For i = 1 To Lr
            If Cells(i, "A").Value <> Cells(i, "B").Value Then
            With Range(Cells(i, "A"), Cells(i, "B"))
                .Interior.ColorIndex = 6
                .Font.Bold = True
            End With
        End If
    Application.ScreenUpdating = True
    Next i
    
    End Sub
    VBA Noob
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

  4. #4
    Registered User
    Join Date
    11-18-2007
    Posts
    29
    A sheets1
    apple
    orange
    banana
    pinapple
    japfruit
    kiwi
    etc

    B sheets2
    apple
    orange
    banana
    pinapple
    japfruit
    starfruit
    etc

    thank if like say the two sets of data is in different sheets, can i know how to code?

  5. #5
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Maybe

    Sub Flag_Diff()
    Dim Lr As Long, i As Long, x As Long
    Lr = Sheets("Sheet1").Cells(Rows.Count, "A").End(xlUp).Row
    
    Application.ScreenUpdating = False
        For i = 1 To Lr
            If Sheets("Sheet1").Cells(i, "A").Value _
            <> Sheets("Sheet2").Cells(i, "B").Value Then
        For x = 1 To 2
          With Sheets("Sheet" & x).Cells(i, x)
                .Interior.ColorIndex = 6
                .Font.Bold = True
          End With
       Next x
    End If
        Next i
    Application.ScreenUpdating = True
    End Sub
    VBA Noob

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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