VBA comparing two files via rows and copy difference to third file
Closed
tatkse11
Posts
1
Registration date
Wednesday November 7, 2018
Status
Member
Last seen
November 7, 2018
-
Updated on Nov 7, 2018 at 12:23 PM
Blocked Profile - Nov 7, 2018 at 02:53 PM
Blocked Profile - Nov 7, 2018 at 02:53 PM
Related:
- VBA comparing two files via rows and copy difference to third file
- Windows 10 iso file download 64-bit - Download - Windows
- Kmspico zip file download - Download - Other
- Tiny 11 iso file download - Download - Windows
- Dvi file - Guide
- Messenger file downloader - Guide
1 response
Well, this was asked a while ago. It is more than one function. I am offering this as is, and I am not going to script it to make it fit into your model, you do that! This has everything you need to cut and paste together your solution.
Please read and understand the example I gave you. I did not build it to work as your example, but scripted it for you to learn.
All you need is the comparison of sheets. What happens when one sheet is only one item off, and you end up with all of sheet 2 on sheet 3 even though the items are on sheet 1? I am not going to code for that trap!
Function sheetexist(whatsheet)
On Error GoTo NotExists
ThisWorkbook.Worksheets(whatsheet).Select
sheetexist = True
Exit Function
NotExists:
sheetexist = False
End Function
Function testsheet(whichsheet, rowNum)
nret = sheetexist(whichsheet)
If nret = False Then makesheet (whichsheet)
nret = copyrowX(whichsheet, rowNum)
End Function
Sub makesheet(whatsheet)
On Error GoTo ExitSub
With ThisWorkbook
.Sheets.Add(After:=.Sheets(.Sheets.Count)).Name = whatsheet
End With
ExitSub:
End Sub
Function copyrowX(towhatsheet, whatrow)
ThisWorkbook.Worksheets("Sheet1").Select
ThisWorkbook.Worksheets("Sheet1").Range("A" & whatrow).EntireRow.Select
Selection.Copy
ThisWorkbook.Worksheets(towhatsheet).Select
cellcount = Cells(ThisWorkbook.Worksheets(towhatsheet).Rows.Count, 1).End(xlUp).Row
ThisWorkbook.Worksheets(towhatsheet).Range("A" & cellcount).EntireRow.Select
Selection.Insert
End Function
Sub ReadSheet()
cellcount = Cells(ThisWorkbook.Worksheets("Sheet1").Rows.Count, 1).End(xlUp).Row
For RowCount = 1 To cellcount
cellvalue = ThisWorkbook.Worksheets("Sheet1").Range("A" & RowCount).Value
nret = testsheet(cellvalue, RowCount)
ThisWorkbook.Worksheets("Sheet1").Select
Next
End Sub
Please read and understand the example I gave you. I did not build it to work as your example, but scripted it for you to learn.
All you need is the comparison of sheets. What happens when one sheet is only one item off, and you end up with all of sheet 2 on sheet 3 even though the items are on sheet 1? I am not going to code for that trap!