VBA code for comparing 2 excel files -
I hope you can help me,
I want to create a macro Excel files will be compared to highlighting the difference between red and white in both sheet 1 and green in their workbooks.
I need to compare lines if the value in cells in column A is the same (WB1 cell A1 is equal to 123-5, 123-5 in WB2 column A and rest of row matches Make sure.)
I want to apologize if it is not understood very well, but this is the best way to explain what I need.
Thank you for your time,
The code below examines everything from the same workbook and different sheets, I need a separate workbook and only columns I>
pre-class = "piece-code -html lang-html prettyprint override" Code> Sub Comparison () Compare Worksheets Worksheets ("Sheet 1"), Worksheets ("Sheet 3") and Subs Subscribed Worksheets (on WS1) Shakesheet, Worksheet as WS2) as the slow diffB in the form of Boolean dim R Long, integer, the meter integer as the dim LR1 long, in the form of LR2 long, LC1 integer, LC2 integer dim maxR long As, as maxc integer, cf1 as string, cf2 as string as in the form of c rptWB dim workbook, DiffCount Long Application.ScreenUpdating = False Application.StatusBar In = "Report made It is ... "Application.DisplayAlerts = ws1.UsedRange LR1 = .ows.Count LC1 = .Columns.Count end with True WS2 along with .UsedRange lr2 = .owsows.count lc2 = .Clumn.Count finished With maxR = lr1 maxC = lc1 if maxR & lt; Lr2 then maxr = lr2 if maxc & lt; LC2 then Maxx = LC2 Definition = 0C = 1 for maximum C, I = 2 to LR 1Defif B = True app. StatSbar = "Comparing cell" & amp; Format (i / maxR, "0%") & amp; "..." for R = 2 LR2 to cf1 = "" cf2 = "" Error resume next cf1 = ws1.Cells (i, c) .FormulaLocal cf2 = ws2.Cells (r, c) Error on FormulaLocal goto 0 if cf1 = cf2 then diffB = false ws1.Cells (i, c) .interior.colorIndex = 19 ws1.Cells (i, c) .Select Selection.Font.Bold = This is true for the end Exit the next r then diffB then DiffCount = DiffCount + 1 ws1.Cells (i, c) .Interior.ColorIndex = 0 ws1.Cells (i, c). Selection Selection.Font.Bold = false end then next I next C Application.StatusBar = "Formatting the report ... .." M = MaxR - Defact - 1 application. StatSbar = mistake application. Screen Updating = True MSBbox M & amp; "Cells have the same value!", VbInformation, "Compare" & amp; Ws1.Name & amp; With "& amp; Ws2.Name End Sub
Comments
Post a Comment