matt_leonard
Board Regular
- Joined
- Dec 20, 2004
- Messages
- 51
Hi,
I have 2 workbooks with some data on. In column B is a ref number. Basically if the ref number is on todays workbook, i need it to pull across the data in 3 columns.
I am trying to do it with 2 loops, but dosent appear to work. It doesnt seem to like the 2nd loop? Can someone please advise me where im going wrong? I am trying the following
If WorkbookExists(Format(Now, "yyyymmdd") - 1 & " Typhoon Pre-allocation.xls") Then ' checks that the events sheet has been exported from GICAD
'Workbooks(Format(Now, "yyyymmdd") & " Typhoon Pre-allocation.xls").Activate
For i = 2 To usedrow
value1 = Cells(i, 2).value
Workbooks(Format(Now, "yyyymmdd") - 1 & " Typhoon Pre-allocation.xls").Activate
usedrow2 = ActiveSheet.Cells.SpecialCells(xlCellTypeLastCell).Row
For a = 2 To usedrow2
If value1 = Cells(a, 2).value Then
match = True
comment1 = Cells(a, 23).value
comment2 = Cells(a, 24).value
comment3 = Cells(a, 25).value
Exit For
Else
match = False
Next a
If match = True Then
transfer.Activate
Cells(i, 23).value = comment1
Cells(i, 24).value = comment2
Cells(i, 25).value = comment3
Else
Next i
End If
thank you
I have 2 workbooks with some data on. In column B is a ref number. Basically if the ref number is on todays workbook, i need it to pull across the data in 3 columns.
I am trying to do it with 2 loops, but dosent appear to work. It doesnt seem to like the 2nd loop? Can someone please advise me where im going wrong? I am trying the following
If WorkbookExists(Format(Now, "yyyymmdd") - 1 & " Typhoon Pre-allocation.xls") Then ' checks that the events sheet has been exported from GICAD
'Workbooks(Format(Now, "yyyymmdd") & " Typhoon Pre-allocation.xls").Activate
For i = 2 To usedrow
value1 = Cells(i, 2).value
Workbooks(Format(Now, "yyyymmdd") - 1 & " Typhoon Pre-allocation.xls").Activate
usedrow2 = ActiveSheet.Cells.SpecialCells(xlCellTypeLastCell).Row
For a = 2 To usedrow2
If value1 = Cells(a, 2).value Then
match = True
comment1 = Cells(a, 23).value
comment2 = Cells(a, 24).value
comment3 = Cells(a, 25).value
Exit For
Else
match = False
Next a
If match = True Then
transfer.Activate
Cells(i, 23).value = comment1
Cells(i, 24).value = comment2
Cells(i, 25).value = comment3
Else
Next i
End If
thank you