View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Ron de Bruin Ron de Bruin is offline
external usenet poster
 
Posts: 11,123
Default Find Next in a selection, how to stop it when it returns to the fi

Try this instead

Sub test()
Dim cell As Range
For Each cell In Selection.SpecialCells(xlCellTypeConstants)
If Len(cell.Value) = 1 Then
cell.Value = "'00" & cell.Value
End If
If Len(cell.Value) = 2 Then
cell.Value = "'0" & cell.Value
End If
Next cell
End Sub


--
Regards Ron de Bruin
http://www.rondebruin.nl


"Keivn Green" <Keivn wrote in message ...
I have a range of cells selected and have a find next statement to find * once it finds * it makes the cell text and fills in 0's

so that whatever number or letter it is will be 3 digits. I have the loop working but cant find a way for it to stop when the first
cell found is selected again, in other words back to the beginning.

here is what I have.
10: Selection.Find(What:="*", After:=ActiveCell, LookIn:=xlValues, LookAt:= _
xlWhole, SearchOrder:=xlByColumns, SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False).Activate


Selection.NumberFormat = "@"
If Len(ActiveCell) = 1 Then
ActiveCell = "00" & ActiveCell.Text
End If
If Len(ActiveCell) = 2 Then
ActiveCell = "0" & ActiveCell.Text
End If
GoTo 10


Any ideas?