Board logo

標題: FIND 的用法 ?? [打印本頁]

作者: t8899    時間: 2018-10-21 22:14     標題: FIND 的用法 ??

我想找 V6:V84 倒數第1個 不等於0 的值
Set b = Range("v6:v84").Find(What:=???, SearchOrder:=xlByRows, LookIn:=xlValues, SearchDirection:=xlPrevious, LookAt:=xlWhole)
作者: GBKEE    時間: 2018-10-24 05:24

回復 1# t8899
FIND 沒有此能力
  1. Option Explicit
  2. Sub Ex()
  3.     Dim i As Integer, b As Range
  4.     With Range("v6:v84")
  5.         For i = .Rows.Count To 1 Step -1
  6.             If IsNumeric(.Cells(i)) And .Cells(i) > 0 Then
  7.                 Set b = .Cells(i)
  8.                 Exit For
  9.             End If
  10.         Next
  11.     End With
  12. End Sub
複製代碼

作者: 准提部林    時間: 2018-10-24 09:53

Sub Macro2()
Dim b As Range
With Range("v6:v84")
     .NumberFormatLocal = "||;||;0"
     Set b = .Find(What:="||", LookIn:=xlValues, SearchDirection:=xlPrevious, LookAt:=xlWhole)
     .NumberFormatLocal = "G/通用格式"
     If Not b Is Nothing Then MsgBox b.Address
End With
End Sub




歡迎光臨 麻辣家族討論版版 (http://forum.twbts.com/)