highest sheet name

G

geebee

hi,

lets say i have a number of sheets, with names like acct1, acct2, acct3,
acct4 and so forth. how can i determine the largest of the name? like from
the above, acct4 is the largest.

thanks in advance,
geebee
 
J

Joel

highnum = 0
For Each sht In ThisWorkbook.Sheets
If Left(sht.Name, 4) = "acct" Then
newhighnum = Val(Mid(sht.Name, 5))
If newhighnum > highnum Then
highnum = newhighnum
End If
End If
Next sht
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top