如何用VBA获取当前页页码
答案:1 悬赏:50 手机版
解决时间 2021-12-25 11:28
- 提问者网友:喧嚣尘世
- 2021-12-24 16:36
如何用VBA获取当前页页码
最佳答案
- 五星知识达人网友:蕴藏春秋
- 2021-12-24 17:40
'以下代码可以确定所选中的单元格所在页的页码
Sub test()
For i = 1 To ActiveSheet.HPageBreaks.Count
If Sheet1.HPageBreaks(i).Location.Row > ActiveCell.Row Then Exit For
Next
For j = 1 To ActiveSheet.VPageBreaks.Count
If ActiveSheet.VPageBreaks(j).Location.Column > ActiveCell.Column Then Exit For
Next
If ActiveSheet.PageSetup.Order = xlOverThenDown Then
MsgBox "选中单元格在第" & (i - 1) * (ActiveSheet.VPageBreaks.Count + 1) + j & "页"
Else
MsgBox "选中单元格在第" & (j - 1) * (ActiveSheet.HPageBreaks.Count + 1) + i & "页"
End If
End Sub
Sub test()
For i = 1 To ActiveSheet.HPageBreaks.Count
If Sheet1.HPageBreaks(i).Location.Row > ActiveCell.Row Then Exit For
Next
For j = 1 To ActiveSheet.VPageBreaks.Count
If ActiveSheet.VPageBreaks(j).Location.Column > ActiveCell.Column Then Exit For
Next
If ActiveSheet.PageSetup.Order = xlOverThenDown Then
MsgBox "选中单元格在第" & (i - 1) * (ActiveSheet.VPageBreaks.Count + 1) + j & "页"
Else
MsgBox "选中单元格在第" & (j - 1) * (ActiveSheet.HPageBreaks.Count + 1) + i & "页"
End If
End Sub
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯