0

我正在尝试将值从一本工作簿复制到当前工作簿,但出现错误:

运行时错误“13”类型不匹配

我尝试了很多但没有得到任何解决方案请帮助我

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
4

1 回答 1

3

wbTarget.Sheets(1).Range("A1:B5").Value返回一个 s 数组Variant。您不能将其存储在String. 声明sValueVariantVariant()

于 2013-05-10T09:01:23.120 回答