来自excel vba的对象变量和块未设置错误

卡西克·拉马钱德兰

我有以下代码,但 excel 给我错误 91:对象变量或块变量未设置错误

它特别突出了我将 lr1 设置为等于 find 公式的那一行。

我不知道它为什么这样做。

请。帮助!

这是代码:

'Start Argument
'This Argument will deal with locating the last empty row and inserting Free Rent & Recoveries Headers
Sub LER()

'The variable lr1 is set as a Long Number
Dim lr1 As Long

'The variable lc1 is set as a Long Number
Dim lc1 As Long

'The variable sr1 is set as a Long Number
Dim sr1 As Long

Sheets("Sheet1").Range("A1").Activate

'The variable lr1 is used to store the find formula to locate the last row of cells containing any data
lr1 = Cells.Find(What:="*", After:=Range("A1"), LookAt:=xlPart, LookIn:=xlFormulas, SearchOrder:=xlByRows, SearchDirection:=xlPrevious, MatchCase:=False).Row

'The variable sr1 is used to go to the truly last row of empty cells with no data whatsoever.
'This is always after the last row of cells with data, hence the "lr1 + 1" formula utilization
sr1 = lr1 + 1

'Cells from the last empty row in coloumns A through G are selected to be merged and centered
Union(Cells(sr1, 1), Cells(sr1, 2), Cells(sr1, 3), Cells(sr1, 4), Cells(sr1, 5), Cells(sr1, 6), Cells(sr1, 7)).Select

MsgBox "The last Cell is:" + sr1

'End of Argument
End Sub
斯科特·霍尔兹曼

将对象限定为它们的父对象:

Dim ws1 as Worksheet
Set ws1 = Worksheets("Sheet1")

With ws1

    Dim rLastCell as Range
    Set rLastCell = .Cells.Find(What:="*", After:=.Range("A1"), LookAt:=xlPart, LookIn:=xlFormulas, SearchOrder:=xlByRows, SearchDirection:=xlPrevious, MatchCase:=False)

    Dim lr1 as Long
    lr1 = rLastCell.Row

    '... more code

End With

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

Excel vba对象变量或With块变量未设置错误

来自分类Dev

Excel vba对象变量或With块变量未设置错误

来自分类Dev

VBA错误91:未设置对象变量或含块变量(Excel 2013)

来自分类Dev

MS Excel 2007 VBA函数错误(对象变量或未设置块变量)

来自分类Dev

VBA错误91:未设置对象变量或With块变量(Excel 2013)

来自分类Dev

VBA Excel SQL 对象变量或未设置块变量

来自分类Dev

在Excel中未设置对象变量或With块变量(错误91)

来自分类Dev

在Excel中未设置对象变量或With块变量(错误91)

来自分类Dev

检查 excel vba 中是否存在 getelementsbyclassname。运行时错误 91 对象变量或块变量未设置

来自分类Dev

EXCEL-对象变量或未设置块变量

来自分类Dev

Excel VBA运行时错误91对象变量未设置

来自分类Dev

VBA for excel 给出“未设置对象变量”或“需要对象”

来自分类Dev

VBA中的对象变量或With块变量未设置错误

来自分类Dev

Excel VBA对象变量未设置问题,可能是Redim使用不当?

来自分类Dev

Excel VBA-对象引用未设置为对象的实例

来自分类Dev

Excel VBA-对象引用未设置为对象的实例

来自分类Dev

VBA:运行时错误 91:未设置对象变量或块变量

来自分类Dev

运行时错误 91 - 对象变量或未设置块变量 - VBA

来自分类Dev

VBA错误91:未设置对象变量

来自分类Dev

VBA错误91:未设置对象变量

来自分类Dev

运行时错误91:未在Excel 2013中设置对象变量或带有块变量

来自分类Dev

VBA中的“未设置对象变量或带块变量”

来自分类Dev

VBA:我得到“对象变量或未设置块变量”

来自分类Dev

未设置对象变量或With块变量(错误91)

来自分类Dev

偏移功能出现“对象变量或未设置块变量”错误

来自分类Dev

getDataArray()和“未设置对象变量”错误

来自分类Dev

VBA .range.find 错误“未设置块变量”

来自分类Dev

来自HTTP responseText VBA Excel的表

来自分类Dev

运行时错误91:未设置对象变量或With块

Related 相关文章

  1. 1

    Excel vba对象变量或With块变量未设置错误

  2. 2

    Excel vba对象变量或With块变量未设置错误

  3. 3

    VBA错误91:未设置对象变量或含块变量(Excel 2013)

  4. 4

    MS Excel 2007 VBA函数错误(对象变量或未设置块变量)

  5. 5

    VBA错误91:未设置对象变量或With块变量(Excel 2013)

  6. 6

    VBA Excel SQL 对象变量或未设置块变量

  7. 7

    在Excel中未设置对象变量或With块变量(错误91)

  8. 8

    在Excel中未设置对象变量或With块变量(错误91)

  9. 9

    检查 excel vba 中是否存在 getelementsbyclassname。运行时错误 91 对象变量或块变量未设置

  10. 10

    EXCEL-对象变量或未设置块变量

  11. 11

    Excel VBA运行时错误91对象变量未设置

  12. 12

    VBA for excel 给出“未设置对象变量”或“需要对象”

  13. 13

    VBA中的对象变量或With块变量未设置错误

  14. 14

    Excel VBA对象变量未设置问题,可能是Redim使用不当?

  15. 15

    Excel VBA-对象引用未设置为对象的实例

  16. 16

    Excel VBA-对象引用未设置为对象的实例

  17. 17

    VBA:运行时错误 91:未设置对象变量或块变量

  18. 18

    运行时错误 91 - 对象变量或未设置块变量 - VBA

  19. 19

    VBA错误91:未设置对象变量

  20. 20

    VBA错误91:未设置对象变量

  21. 21

    运行时错误91:未在Excel 2013中设置对象变量或带有块变量

  22. 22

    VBA中的“未设置对象变量或带块变量”

  23. 23

    VBA:我得到“对象变量或未设置块变量”

  24. 24

    未设置对象变量或With块变量(错误91)

  25. 25

    偏移功能出现“对象变量或未设置块变量”错误

  26. 26

    getDataArray()和“未设置对象变量”错误

  27. 27

    VBA .range.find 错误“未设置块变量”

  28. 28

    来自HTTP responseText VBA Excel的表

  29. 29

    运行时错误91:未设置对象变量或With块

热门标签

归档