A
Arne Hegefors
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!
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!