为什么我的宏中不存在 row() 函数?

发布于 2025-01-20 21:35:36 字数 277 浏览 2 评论 0原文

该宏因编译错误而停止:

“子函数或函数未定义”

并且 Row 突出显示。

我正在使用 Microsoft Excel for Microsoft 365。

Sub test()
    Range(Address(Row(), Column()) & ":" & Address(Row(), Column() + 5)).Select
End Sub

This macro is stopping with a compile error:

"sub or function not defined"

and Row is highlighted.

I am using Microsoft Excel for Microsoft 365.

Sub test()
    Range(Address(Row(), Column()) & ":" & Address(Row(), Column() + 5)).Select
End Sub

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

戈亓 2025-01-27 21:35:36

ROW 函数...如果省略引用,则假定为 ROW 函数所在单元格的引用。行函数

作为您的子例程, test 不在电子表格中,因此不会定义该函数。您可能对行属性感兴趣范围。

ROW Function ... If reference is omitted, it is assumed to be the reference of the cell in which the ROW function appears.Row function

As your sub-routine, test, isn't in a spreadsheet it wouldn't have the function defined. You might be interested in the Row attribute of Range.

遗忘曾经 2025-01-27 21:35:36

这样的东西也许。

Sub GetRowNumberFromCellAddress()
Range("A10").Select ' example

Dim col, row
col = Split(Selection.Address, "$")(1)
row = Split(Selection.Address, "$")(2)

MsgBox "Column is : " & col
MsgBox "Row is : " & row
 
End Sub

请查看下面的链接,以获取更多信息。

https://www.thespreadsheetguru.com/blog/2014/7/7/7/5-different-ways-ways-to-find-to-find-the-the-last-the-last-the-last-row----------------------------------------vba < /a>

Something like this, maybe.

Sub GetRowNumberFromCellAddress()
Range("A10").Select ' example

Dim col, row
col = Split(Selection.Address, "
quot;)(1)
row = Split(Selection.Address, "
quot;)(2)

MsgBox "Column is : " & col
MsgBox "Row is : " & row
 
End Sub

Check out the link below, for more info.

https://www.thespreadsheetguru.com/blog/2014/7/7/5-different-ways-to-find-the-last-row-or-last-column-using-vba

掩于岁月 2025-01-27 21:35:36

谢谢大家!研究您的评论非常有教育意义。尤其是 CBasic2008 的提示让我走上了正确的道路。我想做的是:

Sub test()
    Range(ActiveCell.Offset(0, 0), ActiveCell.Offset(0, 5)).Select
End Sub

Thank you All! Researching your comments was very educational. The tips from CBasic2008, especially, put me on the right track. What I was trying to do was this:

Sub test()
    Range(ActiveCell.Offset(0, 0), ActiveCell.Offset(0, 5)).Select
End Sub
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文