laurenbattaglia
Technical User
I am using VB6 in Excel to do a comparitive of two tables and copy if a vlookup value does not exist in the lookup array. I am using the following code, but the value keeps coming up false.
Dim vLookupValue
Dim C As Integer
Dim lngLastRow As Long
Workbooks.Open FileName:="O:\Lauren\Comparatives\SEC DB TEMP.xls"
Sheets("BALANCE_SHEET".Select
Windows("SEC DB TEMP.xls".Activate
Range("A2".Select
Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
Selection.Sort Key1:=Range("I2", Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
Windows("SEC DATABASE V2.xls".Activate
Sheets("BALANCE_SHEET".Select
Range("A2".Select
Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
Selection.Sort Key1:=Range("I2", Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
'Do comparative to replace old duplicate data
C = 2
lngLastRow = Workbooks("SEC DATABASE V2.xls".Worksheets("Balance_Sheet".Range("I65536".End(xlUp).Row
lngLastRow = lngLastRow + 1
Windows("SEC DATABASE V2.xls".Activate
Sheets("Balance_Sheet".Select
Range("I" & C).Select
vLookupValue = Workbooks("SEC DATABASE V2.xls".Worksheets("Balance_Sheet".Range("I" & C)
Do Until C = lngLastRow
If Application.WorksheetFunction.IsError("VLookup(vLookupValue, '[SEC DATABASE V2.xls]BALANCE_SHEET'!$i$1:$i$" & Range("I1".End(xlDown).Row & ", 1, False)" Then
Windows("SEC DATABASE V2.xls".Activate
Sheets("Balance_Sheet".Select
Range("I" & C).Select
ActiveCell.EntireRow.Copy
Windows("SEC DB TEMP 2.xls".Activate
Sheets("BALANCE_SHEET".Select
Range("A1".Select
Selection.End(xlDown).Select
ActiveCell.Offset(rowOffset:=1, ColumnOffset:=0).Activate
ActiveSheet.Paste
Application.CutCopyMode = False
End If
C = C + 1
Loop
Thanks for any help you can give me,
Lauren
Dim vLookupValue
Dim C As Integer
Dim lngLastRow As Long
Workbooks.Open FileName:="O:\Lauren\Comparatives\SEC DB TEMP.xls"
Sheets("BALANCE_SHEET".Select
Windows("SEC DB TEMP.xls".Activate
Range("A2".Select
Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
Selection.Sort Key1:=Range("I2", Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
Windows("SEC DATABASE V2.xls".Activate
Sheets("BALANCE_SHEET".Select
Range("A2".Select
Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
Selection.Sort Key1:=Range("I2", Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
'Do comparative to replace old duplicate data
C = 2
lngLastRow = Workbooks("SEC DATABASE V2.xls".Worksheets("Balance_Sheet".Range("I65536".End(xlUp).Row
lngLastRow = lngLastRow + 1
Windows("SEC DATABASE V2.xls".Activate
Sheets("Balance_Sheet".Select
Range("I" & C).Select
vLookupValue = Workbooks("SEC DATABASE V2.xls".Worksheets("Balance_Sheet".Range("I" & C)
Do Until C = lngLastRow
If Application.WorksheetFunction.IsError("VLookup(vLookupValue, '[SEC DATABASE V2.xls]BALANCE_SHEET'!$i$1:$i$" & Range("I1".End(xlDown).Row & ", 1, False)" Then
Windows("SEC DATABASE V2.xls".Activate
Sheets("Balance_Sheet".Select
Range("I" & C).Select
ActiveCell.EntireRow.Copy
Windows("SEC DB TEMP 2.xls".Activate
Sheets("BALANCE_SHEET".Select
Range("A1".Select
Selection.End(xlDown).Select
ActiveCell.Offset(rowOffset:=1, ColumnOffset:=0).Activate
ActiveSheet.Paste
Application.CutCopyMode = False
End If
C = C + 1
Loop
Thanks for any help you can give me,
Lauren