LastRow = .UsedRange.Rows(.UsedRange.Rows.Count).Row End With MsgBox "最后一行的行号是:" & LastRow End Sub 这个方法可以快速查找到工作表中数据的边界,但是如果该工作表曾经有过数据,然后被删除,有可能会造成不准确。 三、使用 Find 方法 Find方法类似于Excel的查找功能,可以用于搜索工作表的最后一个单元...
4、n = Range(Column & Rows.Count).End(xlUp).Row End Function 注意,要输入新数据的列可能与我们所查找最后一行时所使用的列不同, 例如,在上例中,我们可以修改为在 B列中查找该列的最后一行,而在 A 列相 应行的下一行中输入新的数据。使用 Find 方法Find 方法在当前工作有数据中进行查找,不需要指定列...
Sub FindLastCell() Dim lastCell As Range Dim lastRow As Long Dim lastColumn As Long ' 查找最后一个非空单元格 Set lastCell = ActiveSheet.Cells.SpecialCells(xlCellTypeLastCell) ' 获取最后一个单元格的行号和列号 lastRow = lastCell.Row lastColumn = lastCell.Column ' 输出最后一个单元格的位置 M...
‘’’’查找工作表中最大的行号可最大的列号 MsgBox "数据单元格的最大行号: " &Cells.Find("*", , , , 1, 2).Row MsgBox "数据单元格的最大列号: " &Cells.Find("*", , , , 2, 2).Column End Sub ★★ Find 常常与FindNext配合使用,下一次再学习FindNext吧! ===有时用以下代码==【...
(A) + 1).Select End Sub Public Function LastRowInColumn(Column As String) As Long LastRowInColumn = Range(Column Rows.Count).End(xlUp).Row End Function 注意,要输入新数据的列可能与我们所查找最后一行时所使用的列不同,例如,在上例中,我们可以修改 为在 B 列中查找该列的最后一行,而在 A ...
PublicFunctionLastRowInColumn(ColumnAsString)AsLong LastRowInColumn = Range(Column & Rows.Count).End(xlUp).Row End Function 使用Find方法 Find方法在当前工作有数据中进行查找,不需要指定列,也可以确保不会意外地覆盖掉已有数据。其中,参数LookIn指定所查找的类型,有三个常量可供选择,即xlValues、xlFormulas和...
excelperfect标签:VBA运行下面的VBA过程,将列出当前工作表中所有合并单元格的地址。程序会新建一个工作表并重命名,然后在其中输入所有合并单元格的地址。详细代码: Sub FindandListMergedCells() Dim LastRow As Long Dim LastColumn As Integer Dim ...
Excel VBA Last Row How To Find Last Used Row In The Column? 1– Using Special Cells To Find Last Row 2– Using Rows.Count For Non-Empty Cells 3– Using Rows.Count For Any Selected Column 4– Using UsedRange To Find Last Row
方法1—点击右上角的按钮,选择“查看公众号”,点击关注 方法2—在添加朋友中搜索excelperfect 方法3—微信扫一扫下面网址中的二维码 http://www.excelperfect.com/wordpress/wp-content/uploads/2014/02/excelperfect.jpg 新浪微博名:...
=xlWhole) If Not rngFound Is Nothing Then strAddr = rngFound.Address Set rngFound = .Find(strSearch, LookIn:=xlValues, lookat:=xlWhole) ' On Error Resume Next Do 'MsgBox (rngFound.Address) Sheets(wrkSheetName).Columns(rngFound.Column).EntireColumn.Delete Set rngFound = .FindNext(rng...