Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I would like to attach a button to a worksheet that executes a string search
in two non contiguous columns. Once an item is found, theoretically, the search would continue after the active cell each time the button is pressed. The code I wrote does this imperfectly. Each time the button is pressed, it moves on to the next item found in the first of the two columns but will not continue to find through the second column in the range (it stops at the first cell in the second column and then returns to the first column and continues the search). Is there a way to search through both columns? Any help received would be most appreciated. Thank you. Here is the code: Dim SearchTarget As String MyRow = Selection.Row Range("G" & MyRow).Activate Set Rng = Range("G:G,O:O") 'search columns G and O With Rng Set FoundCell = .Cells.Find(What:=SearchTarget, _ After:=ActiveCell, LookIn:=xlFormulas, LookAt:= _ xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext, _ MatchCase:=False) End With If FoundCell Is Nothing Then MsgBox SearchTarget & " was not found." Else FoundCell.Activate End If |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
large function in non-continguous array? | Excel Discussion (Misc queries) | |||
Counting Continguous Cell Entries | Excel Discussion (Misc queries) | |||
Searching Columns | Excel Discussion (Misc queries) | |||
Average non continguous cells, excluding zero's | Excel Worksheet Functions | |||
Searching Columns | Excel Discussion (Misc queries) |