doubtfire
08-30-2012, 02:37 PM
I am trying to retrieve data from worksheets of another workbook to the current "this" workbook.
Dim ThisWB As Workbook
Dim ThisWS As Worksheet
Dim AnotherWB As Workbook
Dim AnotherWS As Worksheet
Set ThisWB = ThisWorkbook
Set ThisWS = ThisWB.Worksheets("TargetSheet")
Set AnotherWB = Workbooks.Open(filename:="C:\test1.xlsm", IgnoreReadOnlyRecommended:=True)
Set AnotherWS = AnotherWB.Worksheets("SheetAA")
ThisWS.Range("A1").value = AnotherWS.Range("A1").value
'****This is where system crashes
Set AnotherWS = AnotherWB.Worksheets("SheetBB")
ThisWS.Range("A2").value = AnotherWS.Range("A1").value
Set AnotherWS = AnotherWB.Worksheets("SheetCC")
ThisWS.Range("A3").value = AnotherWS.Range("A1").value
Any ideas? I have tried to use the whole qualified Workbook.Worksheet.Range and it is still crashed.
Thanks.:help
Dim ThisWB As Workbook
Dim ThisWS As Worksheet
Dim AnotherWB As Workbook
Dim AnotherWS As Worksheet
Set ThisWB = ThisWorkbook
Set ThisWS = ThisWB.Worksheets("TargetSheet")
Set AnotherWB = Workbooks.Open(filename:="C:\test1.xlsm", IgnoreReadOnlyRecommended:=True)
Set AnotherWS = AnotherWB.Worksheets("SheetAA")
ThisWS.Range("A1").value = AnotherWS.Range("A1").value
'****This is where system crashes
Set AnotherWS = AnotherWB.Worksheets("SheetBB")
ThisWS.Range("A2").value = AnotherWS.Range("A1").value
Set AnotherWS = AnotherWB.Worksheets("SheetCC")
ThisWS.Range("A3").value = AnotherWS.Range("A1").value
Any ideas? I have tried to use the whole qualified Workbook.Worksheet.Range and it is still crashed.
Thanks.:help