LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Searching in Two Non-Continguous Columns

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
large function in non-continguous array? Ian Elliott Excel Discussion (Misc queries) 2 March 13th 08 08:49 PM
Counting Continguous Cell Entries ConfusedNHouston Excel Discussion (Misc queries) 1 March 12th 08 07:35 PM
Searching Columns mully Excel Discussion (Misc queries) 2 February 3rd 06 12:50 PM
Average non continguous cells, excluding zero's Keithlearn Excel Worksheet Functions 2 April 27th 05 01:22 PM
Searching Columns Aviator Excel Discussion (Misc queries) 3 January 26th 05 11:13 PM


All times are GMT +1. The time now is 06:50 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"