HowTo add a period to front of EVERY text cell in a Excel colu
Just change the Range("A:A") to Range("B:B") eg
Sub Macro1()
Dim myCell As Range
For Each myCell In Range("B:B").SpecialCells(xlCellTypeConstants, 2)
If Left(myCell.Value, 1) < "." Then myCell.Value = "." & myCell.Value
Next myCell
End Sub
Hope this helps
Rowan
adamcollegeman wrote:
Dear Bernie,
thank you so much for the reply,
I have a slight follow on question, which is:
could you show me what this subroutine would look like if the column of text
was column B and I do not know how many rows long it is and adding only one
period at the beginning to each text cell filled with text in that column B?
Thank you! :) I really appreciate your considerations
"Bernie Deitrick" wrote:
Adam,
If you only want one period:
Sub Macro1()
Dim myCell As Range
For Each myCell In Range("A:A").SpecialCells(xlCellTypeConstants, 2)
If Left(myCell.Value, 1) < "." Then myCell.Value = "." & myCell.Value
Next myCell
End Sub
If you want another period whether one exists or not, simply delete this:
If Left(myCell.Value, 1) < "." Then
HTH,
Bernie
MS Excel MVP
"adamcollegeman" wrote in message
...
I want to add a period to the FRONT of each different text string in a column
of text cells, How do I do this?
example
from this to this
KQWLN .KQWLN
ERULM .ERULM
MQMLD .MQMLD
TDQAH .TDQAH
Thank you for your Answer
|