返回列表 上一主題 發帖

[發問] 用 Find 找小於等於(<=)某值 的 Range

回復 1# Scott090


尋找<=某值不一定要用.Find,方法有很多下面說明則是利用VBA,Find的說明範例修改的給你參考
  1. Public Sub Find_1()
  2. A = 5
  3. N = 1
  4. With Worksheets(1).Range("a1:a" & Cells(Rows.Count, "a").End(xlUp).Row)
  5.     Set c = .Find("*", LookIn:=xlValues, SearchDirection:=2)
  6.     If Not c Is Nothing Then
  7.         firstAddress = c.Address
  8.         Do
  9.             If c <= A Then
  10.                 Cells(N, "D") = c.Value
  11.                 N = N + 1
  12.             End If
  13.             Set c = .FindNext(c)
  14.         Loop While Not c Is Nothing And c.Address <> firstAddress
  15.     End If
  16. End With
  17. End Sub
複製代碼

TOP

        靜思自在 : 【做人的開始】每一天都是故人的開始,每一個時刻都是自己的警惕。
返回列表 上一主題