excel - 宏不起作用:“编译错误:不支持对象库功能”
问题描述
每当我运行这个宏时,我都会得到:
编译错误:“不支持对象库功能”并突出显示“设置 ws1 =”。
发生了什么?有什么问题吗?
谢谢
Sub Airpush()
'Define your variables.
Dim ws1 As Worksheet, ws2 As Worksheet, cel As Range, i As Long
'Assign your worksheet variables.
Set ws1 = ThisWorkbook.Sheets("CAMPAIGN_PLANNER")
Set ws2 = ThisWorkbook.Sheets("REPORT_DOWNLOAD")
'First loop through each cell in Sheet2, Column E, (start at row 2 to account
'for header row) to get the value to find in Sheet1, Column C.
For Each cel In ws2.Range("A2:A" & ws2.Range("A" & ws2.Rows.Count).End(xlUp).Row)
'Then loop through each cell in Sheet1, column C. If you get a match, then
'copy the value from Sheet2, column B, cel.row to Sheet1, Column S, i row.
For i = 2 To ws1.Range("L" & ws1.Rows.Count).End(xlUp).Row
If cel.Value = ws1.Cells(i, 3).Value Then
ws1.Cells(i, 3).Offset(, 16).Value = cel.Offset(, 3).Value
ws1.Cells(i, 3).Offset(, 15).Value = cel.Offset(, 4).Value
ws1.Cells(i, 3).Offset(, 17).Value = cel.Offset(, 2).Value
End If
Next i 'loops through every used cell in Column C for all matches
Next cel 'loop to the next cell in Sheets2, Columns E
End Sub
解决方案
我不确定问题出在哪里,但是当我在激活的版本上重新打开 excel 时,宏工作正常,这表明问题与只读版本有关。
感谢所有评论的人!
推荐阅读
- javascript - 是否可以通过 fetch() 设置类成员,以便它们可以在其他类方法中使用?
- python - 如何使用 GUI Tkinter 按钮增加一个数字并显示它
- python - 如何使用 python 从文本文件中复制特定字符串?
- python - 按文件数拆分 gzip 文件
- python - 如何从列表中取出一个数字并放入另一个列表
- google-apps-script - 如何在没有访问管理目录的情况下为 Google Apps 脚本网络应用程序的用户管理不同的角色/权限?
- azure - Azure Functions 设置在门户和本地之间不一致
- keras - keras中的堆叠GRU模型
- java - 计算一个字符串中有多少回文数
- java - 如何增加访问令牌的到期时间?