N
NumberCruncher13
Can someone let me know why I get a type mismatch error when the
following code is ran?
Sub CopyFromLSS()
Dim MyDir As Range, lsFile As Range, csFile As Range
Dim wsTo As Worksheet, wsFrom As Worksheet
Set MyDir = Sheets("WB").Range("B2") 'C:\06\
Set csFile = Sheets("WB").Range("B3") 'CS.xls
Set lsFile = Sheets("WB").Range("B4") 'LS.xls
Set wsFrom = Workbooks(lsFile).Worksheets("Sheet1") 'Why is there
a type mismatch error?
Set wsTo = Workbooks("Copy and Paste.xls").Worksheets("Sheet2")
With wsFrom
.Range("A1:Z1057").Copy
wsTo.Range("A1").PasteSpecial Paste:=xlPasteValues
'etc
End With
Application.CutCopyMode = False
Workbooks(lsFile).Close SaveChanges:=False
End Sub
following code is ran?
Sub CopyFromLSS()
Dim MyDir As Range, lsFile As Range, csFile As Range
Dim wsTo As Worksheet, wsFrom As Worksheet
Set MyDir = Sheets("WB").Range("B2") 'C:\06\
Set csFile = Sheets("WB").Range("B3") 'CS.xls
Set lsFile = Sheets("WB").Range("B4") 'LS.xls
Set wsFrom = Workbooks(lsFile).Worksheets("Sheet1") 'Why is there
a type mismatch error?
Set wsTo = Workbooks("Copy and Paste.xls").Worksheets("Sheet2")
With wsFrom
.Range("A1:Z1057").Copy
wsTo.Range("A1").PasteSpecial Paste:=xlPasteValues
'etc
End With
Application.CutCopyMode = False
Workbooks(lsFile).Close SaveChanges:=False
End Sub