Hello Oreg,
Working with multiple workbooks can be tricky. It is important t
remember to qualify your references fully to avoid getting tripped up
Let's look at your code here...
If bIsBookOpen("SPHistory.xls") Then
Set destWB = Workbooks("SPHistory.xls")
Else
Set destWB = Workbooks.Open("C:\EVEN
TRACKER\TrackerLog\METRO\SPhistory\SPHistory.xls")
End If
Lr = Sheets("sheet1").Range("B" & Rows.Count).End(xlUp).Offset(1
0).Row
Lr1 = Sheets("METRO").Range("B" & Rows.Count).End(xlUp).Offset(0
0).Row
The blue part refers to the destination workbook. The red to the sourc
workbook.
A problem occurs when the destination workbook is opened from you
code. The red statements now no longer reference the source worksheet
Without the source worksheet qualification, the system assumes th
worksheets are those of the active workbook, the destination.
REVISED CODE
With ThisWorkbook
Lr = .Sheets("sheet1").Range("B" & Rows.Count).End(xlUp).Offset(1
0).Row
Lr1 = .Sheets("METRO").Range("B" & Rows.Count).End(xlUp).Offset(0
0).Row
End Wit
--
Leith Ros
-----------------------------------------------------------------------
Leith Ross's Profile:
http://www.excelforum.com/member.php...fo&userid=1846
View this thread:
http://www.excelforum.com/showthread.php?threadid=48097