excel vba执行到 Worksheets(1).Cells(dic(s_v), 10).Paste 说对象不支持该属性或方法,怎么回事 5
PrivateSubCommandButton2_Click()Application.ScreenUpdating=TrueDimdicAsObject,iAsLong...
Private Sub CommandButton2_Click()
Application.ScreenUpdating = True
Dim dic As Object, i As Long
Set dic = CreateObject("Scripting.Dictionary")
Dim xlApp As Excel.Application
Dim xlbook As Excel.Workbook
Dim xlsheet As Excel.Worksheet
Set xlApp = New Excel.Application
Set xlbook = xlApp.Workbooks.Open("D:\EXCEL\ITS电气元器件库.xlsm")
xlApp.Visible = False
For i = 3 To 65536
If Not dic.Exists(Worksheets("Sheet1").Cells(i, 4).Value) Then dic.Add Worksheets("Sheet1").Cells(i, 4).Value, i
Next i
xlApp.Workbooks("ITS电气元器件库.xlsm").Worksheets("Sheet1").Select
For i = 3 To 65536
s_v = xlApp.Workbooks("ITS电气元器件库.xlsm").Worksheets("Sheet1").Cells(i, 4).Value
If dic.Exists(s_v) Then
Cells(dic(s_v), 10) = xlApp.Workbooks("ITS电气元器件库.xlsm").Worksheets("Sheet1").Cells(i, 5)
xlApp.Workbooks("ITS电气元器件库.xlsm").Worksheets("Sheet1").range(Cells(i, 5).Address, Cells(i, 14).Address).Copy
Worksheets(1).Cells(dic(s_v), 10).Paste
End If
Next i
With xlbook
.Close
End With
Set xlsheet = Nothing
Set xlbook = Nothing
Set xlApp = Nothing
End Sub 展开
Application.ScreenUpdating = True
Dim dic As Object, i As Long
Set dic = CreateObject("Scripting.Dictionary")
Dim xlApp As Excel.Application
Dim xlbook As Excel.Workbook
Dim xlsheet As Excel.Worksheet
Set xlApp = New Excel.Application
Set xlbook = xlApp.Workbooks.Open("D:\EXCEL\ITS电气元器件库.xlsm")
xlApp.Visible = False
For i = 3 To 65536
If Not dic.Exists(Worksheets("Sheet1").Cells(i, 4).Value) Then dic.Add Worksheets("Sheet1").Cells(i, 4).Value, i
Next i
xlApp.Workbooks("ITS电气元器件库.xlsm").Worksheets("Sheet1").Select
For i = 3 To 65536
s_v = xlApp.Workbooks("ITS电气元器件库.xlsm").Worksheets("Sheet1").Cells(i, 4).Value
If dic.Exists(s_v) Then
Cells(dic(s_v), 10) = xlApp.Workbooks("ITS电气元器件库.xlsm").Worksheets("Sheet1").Cells(i, 5)
xlApp.Workbooks("ITS电气元器件库.xlsm").Worksheets("Sheet1").range(Cells(i, 5).Address, Cells(i, 14).Address).Copy
Worksheets(1).Cells(dic(s_v), 10).Paste
End If
Next i
With xlbook
.Close
End With
Set xlsheet = Nothing
Set xlbook = Nothing
Set xlApp = Nothing
End Sub 展开
2015-06-09
展开全部
worksheet(1)引用的是该工作簿中的第一个工作表,即引用的是顺序号为1的工作表.
是否表格弄错了.?
是否表格弄错了.?
追问
没有错额,就是Sheet1, 我填“Sheet1”也不行
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询