Reputation: 1006
I am trying to copy values from one work book to current work book but i get the error:
Run-time error '13' Type mismatch
I tried a lot but not get a solution any one please help me out
Sub Update()
Dim sPath As String
Dim sValue As String
Dim wbTarget As Workbook
Dim strName As String
strName = ActiveSheet.Name ' Explicitly provide the sheet name
sPath = "C:\Users\nikhil.surendran\Desktop\1"
Set wbTarget = Workbooks.Open("C:\Users\nikhil.surendran\Desktop\3" & ".xlsx")
sValue = wbTarget.Sheets(1).Range("A1:B5").Value
ThisWorkbook.Sheets(1).Range("A1:B5").Value = sValue
ThisWorkbook.Save
End Sub
Upvotes: 0
Views: 4497
Reputation: 78175
wbTarget.Sheets(1).Range("A1:B5").Value
returns an array of Variant
s. You cannot store that in a String
. Declare sValue
as Variant
or Variant()
.
Upvotes: 3