I need to compare two workbook sheets. If the rows are identical, I ignore. If the data on the row is different I flag the "New" workbook row as modified. If the row does not exist on the "Old" workbook sheet, I flag the "New" workbook as new. The "Old" is extracted from a Sharepoint Workbook (W7 Excell 2010), and the intent is to know what rows need to be modified and what rows need to be updated to put back into Sharepoint. I tried the trick of TRANSPOSE(TRANSPOSE) and even though it looked like it was working, it never found matching rows. Thought that it might be because of empty cell versus spaces and how these two workbooks were created differently (New is xls 2003/2007, sharepoint is the Old and is xlsx). So I gave up on that.
The first column is reserved for my Flag indicator. The second column has a sorted Alphanumeric Key, so if they match I do the balance of the columns (total of 49).
My problem with the logic below, is the Cells.Value does not test as equal for all of the cells that contain numeric values, even though they should. In my searches, I think this is because of the internal storage of numeric values that are floating (0.9999999999 could be a 1). I changed the Advanced Excell Options for both Workbooks to "set precission as displayed", but it still doesn't work. Running Macro on W7 Excel 2007. The Do Whiles work because of the Alphanumeric in column B, it is the IF statement that does not work when the cells contain numbers.
Thanks in advance for the help
Oldx = 2
Newx = 2
Do While Newx < LastRowNew + 1
Status = 1
Do While Workbooks(WkBookNew).Sheets(WkSheetNameNew).Cells(Newx, 2).Value < _
Workbooks(WkBookOld).Sheets(WkSheetNameOld).Cells(Oldx, 2).Value
Workbooks(WkBookNew).Sheets(WkSheetNameNew).Cells(Newx, 1).Value = "New"
Newx = Newx + 1
Loop
Do While Workbooks(WkBookNew).Sheets(WkSheetNameNew).Cells(Newx, 2).Value > _
Workbooks(WkBookOld).Sheets(WkSheetNameOld).Cells(Oldx, 2).Value And _
Oldx < LastRowOld
Workbooks(WkBookOld).Sheets(WkSheetNameOld).Cells(Oldx, 1).Value = "Not"
Oldx = Oldx + 1
Loop
If Workbooks(WkBookNew).Sheets(WkSheetNameNew).Cells(Newx, 2).Value = _
Workbooks(WkBookOld).Sheets(WkSheetNameOld).Cells(Oldx, 2).Value Then
Status = 1
For j = 3 To LastColumnNumber
If Workbooks(WkBookNew).Sheets(WkSheetNameNew).Cells(Newx, j).Value <> _
Workbooks(WkBookOld).Sheets(WkSheetNameOld).Cells(Oldx, j).Value Then
Status = 2
End If
Next j
Else
Status = 3
End If
Newx = Newx + 1
Loop
The first column is reserved for my Flag indicator. The second column has a sorted Alphanumeric Key, so if they match I do the balance of the columns (total of 49).
My problem with the logic below, is the Cells.Value does not test as equal for all of the cells that contain numeric values, even though they should. In my searches, I think this is because of the internal storage of numeric values that are floating (0.9999999999 could be a 1). I changed the Advanced Excell Options for both Workbooks to "set precission as displayed", but it still doesn't work. Running Macro on W7 Excel 2007. The Do Whiles work because of the Alphanumeric in column B, it is the IF statement that does not work when the cells contain numbers.
Thanks in advance for the help
Oldx = 2
Newx = 2
Do While Newx < LastRowNew + 1
Status = 1
Do While Workbooks(WkBookNew).Sheets(WkSheetNameNew).Cells(Newx, 2).Value < _
Workbooks(WkBookOld).Sheets(WkSheetNameOld).Cells(Oldx, 2).Value
Workbooks(WkBookNew).Sheets(WkSheetNameNew).Cells(Newx, 1).Value = "New"
Newx = Newx + 1
Loop
Do While Workbooks(WkBookNew).Sheets(WkSheetNameNew).Cells(Newx, 2).Value > _
Workbooks(WkBookOld).Sheets(WkSheetNameOld).Cells(Oldx, 2).Value And _
Oldx < LastRowOld
Workbooks(WkBookOld).Sheets(WkSheetNameOld).Cells(Oldx, 1).Value = "Not"
Oldx = Oldx + 1
Loop
If Workbooks(WkBookNew).Sheets(WkSheetNameNew).Cells(Newx, 2).Value = _
Workbooks(WkBookOld).Sheets(WkSheetNameOld).Cells(Oldx, 2).Value Then
Status = 1
For j = 3 To LastColumnNumber
If Workbooks(WkBookNew).Sheets(WkSheetNameNew).Cells(Newx, j).Value <> _
Workbooks(WkBookOld).Sheets(WkSheetNameOld).Cells(Oldx, j).Value Then
Status = 2
End If
Next j
Else
Status = 3
End If
Newx = Newx + 1
Loop