Dim LastCell As Range Dim LastRow As Long With ws Set LastCell = .Cells.Find(What:="*", _ After:=.Cells(1, 1), _ LookAt:=xlPart, _ LookIn:=xlFormulas, _ SearchOrder:=xlByRows, _ SearchDirection:=xlPrevious, _ MatchCase:=False) If Not LastCell Is Nothing Then LastRow = Last...
2 在工作表中,点击菜单栏【开发工具】,在其工具栏内,点击【visual basic】!3 会进入VBA编辑界面!点击菜单栏【插入】,在其下拉菜单中,选择【模块】!4 会弹出模块编辑窗口!5 在代码编辑窗口输入以下代码:Sub LookForLastCell()Dim lastrng As RangeSet lastrng = Cells.Find("*", , xlFormulas, xlPart...
示例代码 05Sub Find_LastRowxlFormulas()On Error GoTo Finish'获取最后一行MsgBox &qu 8、ot;最后一行是第 " & Cells.Find("*", _ SearchOrder:=xlByRows, LookIn:=xlFormulas, _ SearchDirection:=xlPrevious).EntireRow.Row &行 ”“Exit Sub Finish:MsgBox "没发现数值或公式! "End Sub 下面再列举...
截图如下:二利用查找完成颜色锁定 我们点击这个工具的运行按钮:点击后,代码会运行,资料找中给出的查找颜色是黄色,代码运行将提示给用户最后查找到的单元格位置,截图如下::本资料内容应用比较广,可以应用在各种场合,有需要的朋友可以参考。Ø代码见程序文件:VBA_FindLastSpecificFillColorCell.xlsm ...
Find方法在当前工作有数据中进行查找,不需要指定列,也可以确保不会意外地覆盖掉已有数据。其中,参数Look In指定所查找的类型,有三个常量可供选择,即xlV al ues、xlForm ulas和xlCom ments。(1) 常量xlFo rmula s将包含零值...
点击后,代码会运行,资料找中给出的查找颜色是黄色,代码运行将提示给用户最后查找到的单元格位置,截图如下:: 本资料内容应用比较广,可以应用在各种场合,有需要的朋友可以参考。 代码见程序文件:VBA_FindLastSpecificFillColorCell.xlsm发布于 2023-11-09 18:46・IP 属地河北 ...
Set LastUsedCell = wksToUse.Cells(1, 1) On Error GoTo Err_Exit Set rngFound = wksToUse.Cells.Find(What:="*", _ LookIn:=xlFormulas, _ LookAt:=xlPart, _ SearchOrder:=xlByRows,_ SearchDirection:=xlPrevious, _ MatchCase:=False) ...
FunctionLastUsedCell(wksToUse As Worksheet)As Range Dim dblRow As Double Dim dblCol As Double Dim rngFound As Range Set LastUsedCell=wksToUse.Cells(1,1)On Error GoTo Err_Exit Set rngFound=wksToUse.Cells.Find(What:="*",_LookIn:=xlFormulas,_LookAt:=xlPart,_SearchOrder:=xlByRows,_Search...
Set Cell = .FindNext(Cell) Loop Until Cell Is Nothing Or Cell.Address = FirstAddress End If End With End Sub ‘- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - [参考] 参见《使VBA代码更快且更简洁的方法》一文中的“使用已有的VBA方法:Find...
[ 示例代码 06] Sub NextRowUsedAsSub() 选取最后一行的下一行 Range(A Cells.Find(*, LookIn:=xlFormulas, SearchDirection:=xlPrevious).Row + 1).Select End Sub [ 示例代码 07] Sub NextRowUsedAsFunction() 选取最后一行的下一行 (调用函数 ) Range(A LastRow + 1).Select End Sub Public ...