Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

need loop that counts text found, then types each incremental value...

Status
Not open for further replies.

Madcow67

Technical User
Aug 23, 2001
28
0
0
US
OK guys, I'm stumped.

I've got a requirement to assign an id to each cell in a table - after it's been converted to the SGML equivalent of the table.

I've got the table already converted, tagged, etc., and I'm trying to come up with a way to find each occurence of this text:

<entry id=&quot;st0.X&quot;

then populate the &quot;X&quot; in the id incrementally as it's found. In other words, the first time it finds the text, the tag will look like this:

<entry id=&quot;st0.1&quot;

then the next:

<entry id=&quot;st0.2&quot;

and so forth. Can anyone help me out on this?

Thanks!



<><><><><><><><><><><><><><><><><><><><><><><><>
Kristina McCook
Director of Technical Engineering Services
Convex Technologies
 
This should get you going - assumes that entries are in column A and that <entry id=&quot;st0.X&quot; is the only text in the cell

lRow = activesheet.range(&quot;A65536&quot;).end(xlup).row
fWhat = <entry id=&quot;st0.X&quot;
ctr = 1
With activesheet.Range(&quot;a1:a&quot; & lRow)
Set c = .Find(fWhat, lookin:=xlValues, lookat:=xlwhole)
If Not c Is Nothing Then
firstAddress = c.Address
Do
c.Value = Left(c.text,len(c.text)-1) & ctr
ctr = ctr + 1
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address <> firstAddress
End If
End With

You can change &quot;Activesheet&quot; to sheets(&quot;Sheetname&quot;) if you want

Rgds, Geoff
Si hoc legere scis, nimis eruditionis habes
Want the best answers to your questions ? - then read me baby one more time - faq222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top