|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
本帖最后由 media888 于 2018-8-11 12:25 编辑
文件打不开
参考代码
Private Sub CommandButton1_Click()
p = Empty
Dim i%, j%, k%, rng As Range
i = ThisWorkbook.Sheets("XXX").Cells(Rows.Count, 1).End(xlUp).Row
Sheet4.Range("a4:a" & i).Interior.ColorIndex = xlNone
For Each rng In Range("a4:a" & i)
If InStr(UCase(rng), UCase(Sheet4.TextBox1)) Then
rng.Interior.ColorIndex = 6
If p = Empty Then
p = rng.Address
End If
End If
Next
If p = "" Then Exit Sub '加入的判断代码
Range(p).Activate
End Sub
|
|