'Copy the values - not headers - from the second sheet to the bottom of the Differences sheet Sht1.Copy Before:=wkbkDBCompare.Worksheets(1) WkbkDBCompare.Worksheets("Differences").Delete 'Create the "Differences" sheet by copying sheet 1 'Prepare the array of compared columns for the Remove Duplicates function If MsgBoxResult1 = vbNo Then sht2.Cells(1, i).EntireColumn.Delete """Cancel"" to Exit and start over", vbYesNoCancel) MsgBoxResult1 = MsgBox("The headers in the first row don't match exactly." & Chr(10) & _ If sht1.Cells(1, i).Value sht2.Cells(1, i).Value Then 'Set the ID cells in the first columns of the two sheets Sht2.Range("A1").PasteSpecial xlPasteValuesAndNumberFormats Set rng2 = Application.InputBox("Select a cell in the database", Default:="=A1", Type:=8) MsgBox "In the next dialog, select a cell in the database from " & wkbk2.Name Wkbk2.Worksheets(1).UsedRange.Address = wkbk1.Worksheets(1).Range("A1").CurrentRegion.Address And _Īpplication.CountBlank(wkbk2.Worksheets(1).UsedRange) = 0 Then MsgBox "In the next dialog, select the second file" Sht1.Range("A1").PasteSpecial xlPasteValuesAndNumberFormats Set rng1 = Application.InputBox("Select a cell in the database", Default:="=A1", Type:=8) MsgBox "In the next dialog, select a cell in the database from " & wkbk1.Name Wkbk1.Worksheets(1).UsedRange.Address = wkbk1.Worksheets(1).Range("A1").CurrentRegion.Address And _Īpplication.CountBlank(wkbk1.Worksheets(1).UsedRange) = 0 Then StrName = Application.GetOpenFilename(Title:="Select first file") MsgBox "In the next dialog, select the first file" If you data sets do not start in A1 with no blanks, then the code will ask you to select the data. Run this macro with the two files closed, and choose them when prompted.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
January 2023
Categories |