Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 110
Default two consescutive finds

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default two consescutive finds

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 110
Default two consescutive finds

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
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
lookup only finds #n/a's Janis Excel Discussion (Misc queries) 4 July 26th 07 11:02 PM
Hiding Rows between two Finds SharonInGa[_2_] Excel Programming 3 March 30th 05 10:57 PM
find next finds too much. No Name Excel Programming 5 January 21st 05 08:00 PM
Only finds first Occurrence Steved[_3_] Excel Programming 2 September 10th 04 01:33 AM
finds and concatenate vikram Excel Programming 3 May 20th 04 02:02 PM


All times are GMT +1. The time now is 07:43 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"