• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Macro for Vlookup and to find Difference each Columns

linga

New Member
Dear all,


Pl find the attachment below.

I need to run macro in Sheet 3

It should take data in sheet1 and sheet2 and to find difference for each columns.

if the value is text and it is different then show as red.

Regards,

Linga
 

Attachments

Hi,

try this demonstration :​
Code:
Sub Demo()
Sheet3.UsedRange.Offset(1).Clear
Application.ScreenUpdating = False
                        L& = 1
With Sheet1.Cells(1).CurrentRegion
    For R& = 2 To .Rows.Count
        If .Cells(R, 4).Value & .Cells(R, 5).Value <> Sheet2.Cells(R, 4).Value & Sheet2.Cells(R, 5).Value Then
            L = L + 1
           .Cells(R, 1).Resize(, 4).Copy Sheet3.Cells(L, 1)
                       .Cells(R, 5).Copy Sheet3.Cells(L, 7)
            With Sheet3
                 Sheet2.Cells(R, 4).Copy .Cells(L, 5)
                 Sheet2.Cells(R, 5).Copy .Cells(L, 8)
                    .Cells(L, 6).Value = .Cells(L, 4).Value - .Cells(L, 5).Value
                 If .Cells(L, 8).Value <> .Cells(L, 7).Value Then .Cells(L, 8).Font.ColorIndex = 3
            End With
        End If
    Next
End With
            Application.Goto Sheet3.Cells(1), True
End Sub
Do you like it ? So thanks to click on bottom right Like !
 
what if you want it to run on 2 active sheets or work books name not mattering .
and msg box pops up for each step like you would write a formula in excel.
so you can select what column you are comparing and where you want to place the results?
 
Back
Top