Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 244
Default Looper blooper

Hi! I have a problem with a loop. I want to search the entire worksheet for a
cell that contains the text "Sec type". However there is one cell that
contains "Sec type" that I do not want to search, ie if that cell is the only
one found containing "Sec type" then the search will have found nothig. Thus,
the cell (or the row) that I do not want search is SecID.row. Now the loop
searches the spreadsheet but stores in c the forbidden SecID cell. My code:

With Range("b1:aa5000")
Set c = Worksheets("Beräkning").Cells.Find("Sec type",
LookIn:=xlValues)
If Not c Is Nothing Then
firstAddress = c.Address
Do
Set c = .FindNext(c)
Loop While Not c Is Nothing And (c.Address < firstAddress And
(c.row = segment.row Or c.row = secID.row))
End If
End With

I assume that the problem is on the Loop row in the code but I do not know
how to write this. Please help! Thank you very much in advance!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Looper blooper

You can't stop it from finding the forbidden cell - you would write your code
to ignore it when it is found. Since your code doesn't actually do anything,
it would be difficult to advise.

With Range("b1:aa5000")
Set c = Worksheets("Beräkning").Cells.Find("Sec type",
LookIn:=xlValues)
If Not c Is Nothing Then
firstAddress = c.Address
Do
if c.row = segment.row Or c.row = secID.row then
' do nothing
else
' do something
end if
Set c = .FindNext(c)
Loop While c.Address < firstAddress
End If
End With

--
Regards,
Tom Ogilvy

"Arne Hegefors" wrote:

Hi! I have a problem with a loop. I want to search the entire worksheet for a
cell that contains the text "Sec type". However there is one cell that
contains "Sec type" that I do not want to search, ie if that cell is the only
one found containing "Sec type" then the search will have found nothig. Thus,
the cell (or the row) that I do not want search is SecID.row. Now the loop
searches the spreadsheet but stores in c the forbidden SecID cell. My code:

With Range("b1:aa5000")
Set c = Worksheets("Beräkning").Cells.Find("Sec type",
LookIn:=xlValues)
If Not c Is Nothing Then
firstAddress = c.Address
Do
Set c = .FindNext(c)
Loop While Not c Is Nothing And (c.Address < firstAddress And
(c.row = segment.row Or c.row = secID.row))
End If
End With

I assume that the problem is on the Loop row in the code but I do not know
how to write this. Please help! Thank you very much in advance!

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
Looper blooper Arne Hegefors Excel Programming 3 August 1st 06 03:19 PM
Looper Blooper stendahl_jones Excel Programming 1 June 20th 06 12:34 PM


All times are GMT +1. The time now is 09:05 PM.

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

About Us

"It's about Microsoft Excel"