Punctuation in Excel

  • Thread starter Thread starter Mon
  • Start date Start date
M

Mon

Help again:(

It is possible to insert a full stop after ever sentence automatically
in Excel, without having to go into each cell one by one?


Thanks in advance:)

Mon
 
Hi Mon
one way (assuming that each cell contains only one sentence) you can
use the following macro:
Sub Sentence()
Dim rng As Range
Dim c As Range
Set rng = Selection
For Each c In rng
c.Value = c.Value & "."
Next
End Sub
This will add a full stop at the end of each cell you have selected


Another way would be to insert a code similar to the above in the
worksheet_change event (the following will add a full stop to every
entry in column C):
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Dim c as range
If Target.Column <> 3 Then Exit Sub
On Error GoTo CleanUp
Application.EnableEvents = False
For Each c In Target
c.Value = c.Value & "."
Next
CleanUp:
Application.EnableEvents = True
End Sub

HTH
Frank
 
Back
Top