Word VBA 如何获取当前选择区总行数

Word VBA 如何获取当前选择区总行数,第1张

Sub Macro2()

Dim r, p, r0, p0, rr, pp

p= SelectionInformation(wdActiveEndPageNumber) '当前页码

r= SelectionInformation(wdFirstCharacterLineNumber) '当前行

'数行数

p0 = p

rr = r

Do

SelectionMoveDown Unit:=wdLine, Count:=1

pp = SelectionInformation(wdActiveEndPageNumber)

r0 = SelectionInformation(wdFirstCharacterLineNumber)

If pp > p Then

'退回原处

SelectionMoveUp Unit:=wdLine, Count:=(rr - r + 1)

Exit Do

End If

If rr = r0 Then

'退回原处

SelectionMoveUp Unit:=wdLine, Count:=(rr - r)

Exit Do

End If

rr = r0

Loop

MsgBox "当前页码:" & p & vbCrLf & "本页总行数:" & rr

End Sub

Sub test()

Dim a As Range, c As Range

Set a = Selection

b = ApplicationWorksheetFunctionLarge(a, 1)

Set c = aFind(b)

MsgBox cRow

End Sub

选中要查找数据,运行这个宏,如果是固定区域,把Selection替换为你的区域就行了

PS:你的这列数字最大值是30,=。=

以上就是关于Word VBA 如何获取当前选择区总行数全部的内容,包括:Word VBA 如何获取当前选择区总行数、10 13 30 22 16 24 19 21 26 12 28 14 16 11 11 20 28 22 怎么用VBA得到这列数中最大值28的行号,、等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址: https://www.outofmemory.cn/web/9627149.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-30
下一篇 2023-04-30

发表评论

登录后才能评论

评论列表(0条)

保存