- 帖子
- 17
- 主題
- 4
- 精華
- 0
- 積分
- 58
- 點名
- 1
- 作業系統
- Win 7
- 軟體版本
- Office 2010
- 閱讀權限
- 20
- 註冊時間
- 2015-3-15
- 最後登錄
- 2026-3-21
|
[分享] 在range中尋找自已想要的值,並且底格變色
給各位作分享了,小弟也是從論壇上找資料自已編譯的。
Sub Find()
Dim FindString As Integer
Dim FirstAddress As String
FindString = InputBox("請輸入數值")
Dim oRng As Range
Set oRng = Range("E1:I3000").Find(what:=FindString, LookIn:=xlValues, lookat:=xlWhole, searchorder:=xlRows, matchbyte:=True)
If Not oRng Is Nothing Then
FirstAddress = oRng.Address
Do
Debug.Print oRng.Row, oRng.Address, oRng.Value
Set oRng = Range("E1:I3000").FindNext(oRng)
oRng.Interior.ColorIndex = 4
oRng.Offset(0, 7).Interior.ColorIndex = 4
Loop While Not oRng Is Nothing And oRng.Address <> FirstAddress
End If
End Sub |
|