S
Stephen
Hi Folks,
i'm working on comparing column A in two workbooks and having the
differences reported back either to a sheet in workbook1 or a new workbook.
The code below runs without error but does not return any values and i know
there are differences which should be reported.
There is probably something wrong with my comparison but I'm not sure what
it is.
What i'd like to happen is for the macro to find values in column A that do
not appear in both workbooks and return the values for column A, B, and C.
Dim xlsFilePath As String
xlsFilePath = Application.GetOpenFilename
Application.Workbooks.Open xlsFilePath
MsgBox ("Path & File is " & xlsFilePath)
MsgBox ("File is " & ActiveWorkbook.Name)
Set mstrBook = Workbooks("NJ Pay Rate Check.xls")
Set mstrSheet = mstrBook.Sheets("Rate Check")
Set cmprBook = Workbooks(ActiveWorkbook.Name)
Set cmprSheet = cmprBook.Sheets("NJ Union Contract Raise Report")
Set newbk = Workbooks.Add
Set newbk_sht = newbk.Sheets("Sheet1")
NewbkRowCount = 1
With mstrSheet
LastRow = .Range("A200")
For RowCount = 6 To LastRow
If .Range("A" & RowCount) <> "" Then
empNum = .Range("A" & RowCount)
With cmprSheet
Set c = .Columns("A:A").Find(what:=empNum, _
LookIn:=xlValues, lookat:=xlWhole)
End With
If c Is Nothing Then
.Rows(RowCount).Copy _
Destination:=newbk_sht.Rows(NewbkRowCount)
NewbkRowCount = NewbkRowCount + 1
End If
End If
Next RowCount
End With
Any help is greatly appreciated.
i'm working on comparing column A in two workbooks and having the
differences reported back either to a sheet in workbook1 or a new workbook.
The code below runs without error but does not return any values and i know
there are differences which should be reported.
There is probably something wrong with my comparison but I'm not sure what
it is.
What i'd like to happen is for the macro to find values in column A that do
not appear in both workbooks and return the values for column A, B, and C.
Dim xlsFilePath As String
xlsFilePath = Application.GetOpenFilename
Application.Workbooks.Open xlsFilePath
MsgBox ("Path & File is " & xlsFilePath)
MsgBox ("File is " & ActiveWorkbook.Name)
Set mstrBook = Workbooks("NJ Pay Rate Check.xls")
Set mstrSheet = mstrBook.Sheets("Rate Check")
Set cmprBook = Workbooks(ActiveWorkbook.Name)
Set cmprSheet = cmprBook.Sheets("NJ Union Contract Raise Report")
Set newbk = Workbooks.Add
Set newbk_sht = newbk.Sheets("Sheet1")
NewbkRowCount = 1
With mstrSheet
LastRow = .Range("A200")
For RowCount = 6 To LastRow
If .Range("A" & RowCount) <> "" Then
empNum = .Range("A" & RowCount)
With cmprSheet
Set c = .Columns("A:A").Find(what:=empNum, _
LookIn:=xlValues, lookat:=xlWhole)
End With
If c Is Nothing Then
.Rows(RowCount).Copy _
Destination:=newbk_sht.Rows(NewbkRowCount)
NewbkRowCount = NewbkRowCount + 1
End If
End If
Next RowCount
End With
Any help is greatly appreciated.