完整介绍Excel End(xlUp).Row
时间:2022-11-24 15:24:23
一、End(xlUp).Row介绍
功能是返回一个 Range 对象,该对象代表包含源区域的区域尾端的单元格。等同于按键 End+ 向上键、End+ 向下键、End+ 向左键或 End+ 向右键。Range 对象,只读。
其语法如下:
expression.End(Direction)
expression 必需。 该表达式返回“应用于”列表中的对象之一。
Direction XlDirection 类型,必需。所要移动的方向。
XlDirection 可为 XlDirection 常量之一。
xlDown
xlToRight
xlToLeft
xlUp
二、End(xlUp).Row示例
本示例选定包含单元格 B4 的区域中 B 列顶端的单元格。
Range("B4").End(xlUp).Select
本示例选定包含单元格 B4 的区域中第 4 行尾端的单元格。
Range("B4").End(xlToRight).Select
本示例将选定区域从单元格 B4 延伸至第四行最后一个包含数据的单元格。
Worksheets("Sheet1").Activate
Range("B4", Range("B4").End(xlToRight)).Select
再比如:
Range("a65536").End(xlUp).Row A列数据区域最后一行的行号
Range("b65536").End(xlUp).Row B列数据区域最后一行的行号
Range("d65536").End(xlUp).Row D列数据区域最后一行的行号
Range("k65536").End(xlUp).Row K列数据区域最后一行的行号
最后,再看看一段VBA调用的代码吧:
Dim i, M, iRow, sh, arr
M = 0.0015
For Each sh In ThisWorkbook.Sheets
iRow = sh.[D65535].End(xlUp).Row
ReDim arr(1 To iRow, 1 To 2)
arr = sh.Range("D3:E" & iRow)
For i = 2 To UBound(arr)
arr(i, 1) = arr(i, 1) * M
arr(i, 2) = arr(i, 2) * M
Next
arr(1, 1) = Application.Substitute(arr(1, 1), "平方米", "亩")
arr(1, 2) = Application.Substitute(arr(1, 2), "平方米", "亩")
sh.Range("D3:E" & iRow) = arr
Next
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
word文档怎么生成目录以及怎么微调目录?
![](https://img.aspxhome.com/file/2023/9/27089_0s.jpg)
word添加文献引用的方法步骤
Excel 数据库函数条件区域怎样设置
![](https://img.aspxhome.com/file/2023/2/36072_0s.jpg)
word 目录怎么做的方法:先定义和应用应用样式和格式,然后Word提取自动生成目录
![](https://img.aspxhome.com/file/2023/6/33336_0s.gif)
怎样在word中输入公式?在word中输入公式介绍
![](https://img.aspxhome.com/file/2023/6/24086_0s.jpg)
制作excel表格目录的方法
![](https://img.aspxhome.com/file/2023/8/36138_0s.jpg)
Win10怎么用键盘关机?Win10键盘关机技巧
![](https://img.aspxhome.com/file/2023/7/49827_0s.png)
ThinkPad R490电脑怎么装Win10系统?ThinkPad R490电脑一键安装Win10教学
![](https://img.aspxhome.com/file/2023/7/46367_0s.png)
win10以太网是什么?win10以太网是啥意思?
![](https://img.aspxhome.com/file/2023/2/47592_0s.png)
edge安装第三方插件要避开哪些坑?简单4步教你安装插件
![](https://img.aspxhome.com/file/2023/6/47096_0s.gif)
如何在Word2010文档中组合图形
![](https://img.aspxhome.com/file/2023/0/29840_0s.jpg)
怎样把Excel表格作为图片插入Word中
word2013中,如何把表格转换为文字
![](https://img.aspxhome.com/file/2023/4/18784_0s.jpg)
win10系统重启后一直黑屏在转圈怎么办?win10系统重启后一直黑屏在转圈教程
![](https://img.aspxhome.com/file/2023/5/48035_0s.png)
Win10专业版怎么关闭禁用UAC设置?
![](https://img.aspxhome.com/file/2023/1/49881_0s.jpg)
word文档如何保存为pdf格式
Win10电脑分辨率怎么设置?
![](https://img.aspxhome.com/file/2023/2/51642_0s.png)
Word 里文字怎么总是对不齐?这个方法好多人都不知道!
![](https://img.aspxhome.com/file/2023/8/32558_0s.jpg)
word2003打不开doc文件怎么办
在Word2003中双面打印Word文档
![](https://img.aspxhome.com/file/2023/7/30497_0s.jpg)