+ Reply to Thread
Results 1 to 4 of 4

Import two txt files in excel and highlights the differece b/w two files data

  1. #1
    Registered User
    Join Date
    07-12-2019
    Location
    Germany
    MS-Off Ver
    Office365
    Posts
    61

    Import two txt files in excel and highlights the differece b/w two files data

    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

  2. #2
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow

    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 …

  3. #3
    Registered User
    Join Date
    07-12-2019
    Location
    Germany
    MS-Off Ver
    Office365
    Posts
    61

    Re: Import two txt files in excel and highlights the differece b/w two files data

    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

  4. #4
    Registered User
    Join Date
    07-12-2019
    Location
    Germany
    MS-Off Ver
    Office365
    Posts
    61

    Re: Import two txt files in excel and highlights the differece b/w two files data

    Anybody? heilp me to correct this code

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Excel macro to import data from many files
    By Lulea in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 01-17-2017, 08:13 AM
  2. Data import from .xls files into excel
    By booo in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-05-2010, 06:19 PM
  3. Import data between excel files
    By losmi8 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 09-15-2010, 03:32 PM
  4. Browse for excel data files to import
    By Snoopy2003 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-28-2010, 02:42 AM
  5. Import data from other excel files
    By Mandeep Dhami in forum Excel General
    Replies: 1
    Last Post: 04-24-2006, 05:15 AM
  6. Import data from multiple excel files
    By Arlan in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-22-2005, 04:25 PM
  7. [SOLVED] few excel files :Import External Data
    By chris in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-03-2005, 06:06 PM

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