Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
recently while trying to find solution I have to configure two consecutive
finds. further on when i want to do findnext of the first find the programme did findnext of only the second find and not the first one (sorry the question has become convolute).some extract and comments are given below the entries data and data1 are interspersed with some other data and the entries data and data1 are repeated. the code is something like this Dim cellsfind As Range Dim cellsfind1 As Range Set cellsfind = Cells.Find("data", lookat:=xlWhole) MsgBox cellsfind 'it is <data Set cellsfind1 = Cells.Find("data1", lookat:=xlWhole) MsgBox cellsfind1 'it is <data1 cellsfind1.Select Set cellsfind = Cells.FindNext(cellsfind) MsgBox cellsfind 'it is again data1 and not data which I thought it should be as I used <cellsfind variable code ends where do I do the mistake. ofcourse i solved the problem by a pedestrian and inelegant method of after the first set of finds looping the same <find codes till the loop reaches the end of the range (without using find next) thanks and regards. |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Dim cellsfind As Range
Dim cellsfind1 As Range MsgBox cellsfind 'it is <data Set cellsfind1 = Cells.Find("data1", lookat:=xlWhole) MsgBox cellsfind1 'it is <data1 cellsfind1.Select Set cellsfind = Cells.Find("data", After:CellsFind,lookat:=xlWhole) FindNext refers to the last find executed. -- Regards, Tom Ogilvy "R.VENKATARAMAN" wrote in message ... recently while trying to find solution I have to configure two consecutive finds. further on when i want to do findnext of the first find the programme did findnext of only the second find and not the first one (sorry the question has become convolute).some extract and comments are given below the entries data and data1 are interspersed with some other data and the entries data and data1 are repeated. the code is something like this Dim cellsfind As Range Dim cellsfind1 As Range Set cellsfind = Cells.Find("data", lookat:=xlWhole) MsgBox cellsfind 'it is <data Set cellsfind1 = Cells.Find("data1", lookat:=xlWhole) MsgBox cellsfind1 'it is <data1 cellsfind1.Select Set cellsfind = Cells.FindNext(cellsfind) MsgBox cellsfind 'it is again data1 and not data which I thought it should be as I used <cellsfind variable code ends where do I do the mistake. ofcourse i solved the problem by a pedestrian and inelegant method of after the first set of finds looping the same <find codes till the loop reaches the end of the range (without using find next) thanks and regards. |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
thank you. But I apologise I did not explain properly. the range contains
data and data1 repeatedl;y; I want to find both data and data1 succesively to find out the number of intervening cells in each set and then take some action my inelegant sub is like this (I did not use findnext) Public Sub test() Range("a1").Activate Dim i As Integer Dim j As Integer Dim add1 Cells.Find("data", lookat:=xlWhole, after:=ActiveCell).Activate add1 = ActiveCell.Address MsgBox add1 Cells.Find("data1", lookat:=xlWhole, after:=ActiveCell).Activate MsgBox ActiveCell.Address Do Cells.Find("data", lookat:=xlWhole, after:=ActiveCell).Activate If ActiveCell.Address = add1 Then Exit Sub MsgBox ActiveCell.Address Cells.Find("data1", lookat:=xlWhole, after:=ActiveCell).Activate MsgBox ActiveCell.Address Loop End Sub regards r.venkataraman ============== "Tom Ogilvy" wrote in message ... Dim cellsfind As Range Dim cellsfind1 As Range MsgBox cellsfind 'it is <data Set cellsfind1 = Cells.Find("data1", lookat:=xlWhole) MsgBox cellsfind1 'it is <data1 cellsfind1.Select Set cellsfind = Cells.Find("data", After:CellsFind,lookat:=xlWhole) FindNext refers to the last find executed. -- Regards, Tom Ogilvy "R.VENKATARAMAN" wrote in message ... recently while trying to find solution I have to configure two consecutive finds. further on when i want to do findnext of the first find the programme did findnext of only the second find and not the first one (sorry the question has become convolute).some extract and comments are given below the entries data and data1 are interspersed with some other data and the entries data and data1 are repeated. the code is something like this Dim cellsfind As Range Dim cellsfind1 As Range Set cellsfind = Cells.Find("data", lookat:=xlWhole) MsgBox cellsfind 'it is <data Set cellsfind1 = Cells.Find("data1", lookat:=xlWhole) MsgBox cellsfind1 'it is <data1 cellsfind1.Select Set cellsfind = Cells.FindNext(cellsfind) MsgBox cellsfind 'it is again data1 and not data which I thought it should be as I used <cellsfind variable code ends where do I do the mistake. ofcourse i solved the problem by a pedestrian and inelegant method of after the first set of finds looping the same <find codes till the loop reaches the end of the range (without using find next) thanks and regards. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
lookup only finds #n/a's | Excel Discussion (Misc queries) | |||
Hiding Rows between two Finds | Excel Programming | |||
find next finds too much. | Excel Programming | |||
Only finds first Occurrence | Excel Programming | |||
finds and concatenate | Excel Programming |