ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   HowTo add a period to front of EVERY text cell in a Excel column (https://www.excelbanter.com/excel-programming/346410-howto-add-period-front-every-text-cell-excel-column.html)

adamcollegeman

HowTo add a period to front of EVERY text cell in a Excel column
 
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

Bernie Deitrick

HowTo add a period to front of EVERY text cell in a Excel column
 
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




adamcollegeman

HowTo add a period to front of EVERY text cell in a Excel colu
 
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





Rowan Drummond[_3_]

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





adamcollegeman

HowTo add a period to front of EVERY text cell in a Excel colu
 
Thank you! Rowan and Bernie, have a great thanksgiving.

"Rowan Drummond" wrote:

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






All times are GMT +1. The time now is 07:33 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com