Hallo,
I want to write a macro that import two .txt files in excel and highlights the difference between the data in both files. please help me out![]()
Hallo,
I want to write a macro that import two .txt files in excel and highlights the difference between the data in both files. please help me out![]()
Hallo !
Start to write your code and if any help is necessary post it here according to forum rules with code tags or just using the code icon
with a crystal clear complete explanation of the need with an attachment of source text files and an expected result workbook …
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;C:\Users\Desktop\file1.txt" _
, Destination:=Range("$A$1"))
.Name = "file1"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 437
.TextFileStartRow = 1
.TextFileParseType = xlFixedWidth
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = False
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(1, 1, 1, 1, 1)
.TextFileFixedColumnWidths = Array(16, 1, 53, 7)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With
Range("F1").Select
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;C:\Users\Desktop\file2.txt""" _
, Destination:=Range("$F$1"))
.Name = "file2"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 437
.TextFileStartRow = 1
.TextFileParseType = xlFixedWidth
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = False
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(1, 1, 1, 1, 1)
.TextFileFixedColumnWidths = Array(16, 1, 53, 7)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With
For i = 1 To Sheets("sheet1").Range(Sheets("sheet1").Rows.Count, "C").End(xlUp).Row
If Sheets(Sheet1).Cells(i, 3).Value = Sheets(Sheet1).Cells(i, 8).Value Then
Cells(i, 3).Interior.ColorIndex = 2 ' 2 indicates white Color
Cells(i, 8).Interior.ColorIndex = 2 ' 2 indicates white Color
End If
Cells(i, 3).Interior.ColorIndex = 5 ' 5 indicates Blue Color
Cells(i, 8).Interior.ColorIndex = 5 ' 5 indicates Blue Color
Next i
End Sub
I recorded the macro and imported two txt files now i want to compare column c with column H in the same sheet if the value matches in both cells then both cells should be colored white if not then colored with blue.
I know this is unefficient method and i am getting error during cell comparison. Every time i will import two different files in the same sheet hence import method should be changed and also the comparison error needs to be removed.
So Please help me to correct this code. Thank you
Anybody? heilp me to correct this code![]()
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks