Compare between two columns and highlight unmatched columns

Aswinraj

Board Regular
Joined
Dec 10, 2015
Messages
65
Hello Guys,

I return a code where macro will select available column and paste it in Sheet2 (from Column B2 as transpose ) and compare the data which is available in Column A by highlighting the unmatched columns.
This code works for single file. But I have more than 15 files in a folder.

All i need is, macro should open each files which is present inside specific folder and Enter the File name in C1 and paste the columns headers from C2 (Transpose way)..,
Below code will paste file 1 Headers in Column B from..,
similarly for File 2 - File Name should be pasted in C1 and Column headers should be pasted from C2 (Paste Special - Transpose)..,
followed by File 3 - File Name should be pasted in D1 and Column headers should be pasted from D2 (Paste Special - Transpose)..,
and goes on till last file..,


VBA Code:
    Workbooks("Formatting.xlsx").Activate
    Sheets("Sheet2").Select
    Range("B2").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=True
 
        Dim n As Integer
        Dim valE As Double
        Dim valI As Double
        Dim i As Integer
        n = 100
        Application.ScreenUpdating = False

        For i = 2 To n
        valA = Worksheets("Sheet2").Range("A" & i).Value
        valB = Worksheets("Sheet2").Range("B" & i).Value
            If valA = valB Then
            Else
               Worksheets("Sheet2").Range("B" & i).Interior.Color = RGB(255, 0, 0)
            End If
        Next i
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"

Forum statistics

Threads
1,214,807
Messages
6,121,679
Members
449,047
Latest member
notmrdurden

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top