Home |
Search |
Today's Posts |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
It was not clear to me from your initial posting what you wanted to do with
the row numbers. Here is a modification to my previously posted code to put the row numbers in an array named RowNumbers with indexes from 1 to the number of rows meeting your criteria. Dim X As Long, Index As Long, RowNumbers() As Long Dim R As Range, SearchRange As Range, RowSlice As Range, Joined As String Set SearchRange = Intersect(ActiveSheet.UsedRange, _ Union(Range("A:B"), Columns("D"))) ReDim RowNumbers(1 To SearchRange.Rows.Count) For X = 1 To SearchRange.Rows.Count Set RowSlice = Intersect(Rows(X), SearchRange) Joined = "" For Each R In RowSlice Joined = Joined & Chr(1) & R.Value Next If InStr(1, Joined, "Keyword1", vbTextCompare) 0 And _ InStr(1, Joined, "Keyword2", vbTextCompare) 0 Then Index = Index + 1 RowNumbers(Index) = X End If Next ReDim Preserve RowNumbers(1 To Index) ' Let's see the results For X = 1 To UBound(RowNumbers) MsgBox RowNumbers(X) Next The last three lines just show you the result of the code above them... at this point in the code, you would simply process the RowsNumbers array as needed rather then MessageBox'ing them. -- Rick (MVP - Excel) "u473" wrote in message ... Thanks a lot, you were right for my test sample. It works fine, however, how do I handle it if I have more than one answer ? I will try putting the answer in a loop. |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Copying rows values on one sheet to part of a formula in a column | Excel Discussion (Misc queries) | |||
finding, sorting, put only part of a cell | Excel Worksheet Functions | |||
Finding MAX Value of Part of Cell Contents | Excel Programming | |||
finding part of fole path | Excel Worksheet Functions | |||
Deleting rows A to E when finding dublicated Data in Column B | Excel Programming |