Thread: Offset.Value
View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Offset.Value

Or you could skip counting the dots and let them represent themselves.

Option Explicit

Sub IndentListWithSpaces()

'Run down list and indent cell values to right,
'dependent on number of dots in string

Dim rgListItem As Range
Dim r As Integer
Dim c As Integer
Dim Answer As Long

'Check user selects cell at top of list
Answer = MsgBox(Prompt:="Is cell at top of list selected?", _
Buttons:=vbYesNo + vbQuestion)
If Answer = vbNo Then Exit Sub

r = ActiveCell.Row
c = ActiveCell.Column

Do
Set rgListItem = Cells(r, c)
If IsEmpty(Cells(r, c)) Then Exit Do
With rgListItem.Offset(0, 1)
.Value = Replace(rgListItem.Text,"."," ") & .Value
' or for xl97
' .Value = Application _
' .Substitute(rgListItem.Text,"."," ") & .Value
End With
r = r + 1
Loop

Cells(r, c).Select

MsgBox "Finished"

End Sub

--
Regards,
Tom Ogilvy