Use Range Find Method in a specific column

后端 未结 2 1386
没有蜡笔的小新
没有蜡笔的小新 2021-01-21 05:24

I have been tinkering with this for a while now, I have the below code working but it searches more than I would like it to. I would like it to just search column C and not the

2条回答
  •  猫巷女王i
    2021-01-21 05:40

    I would try it like this

    • ensure you start searching from C1 in case there are multiple matches (given you are setting a scrollwindow)
    • xlFormulas finds cells in hidden rows, xlValues skips them
    • no need for the Select

      Dim rng1 As Range
      Set rng1 = Sheets("State Agent List").Range("C1:C10000").Find(CStr(ComboBox22.Value), [c10000], xlFormulas, xlPart, , xlNext)
      
      If Not rng1 Is Nothing Then
          ActiveWindow.ScrollRow = rng1.Row
      Else
          MsgBox "Location not listed."
      End If
      

提交回复
热议问题