macro to add alpha character to cell contents

J

Janna

I would like a macro that if a cell in a column (for
example, column B) contains more than 11 characters, to
add an "M" to the contents of the cell. Is this possible?

Thanks in advance.
 
J

JE McGimpsey

One way:

Public Sub AddM()
Dim rCell As Range
For Each rCell in Range("B1:B" & _
Range("B" & Rows.Count).End(xlUp).Row)
If Len(rCell.Text) > 11 Then _
rCell.Value = rCell.Text & "M"
Next rCell
End Sub
 
J

Janna

Perfect--Just what I needed. Thanks!
-----Original Message-----
One way:

Public Sub AddM()
Dim rCell As Range
For Each rCell in Range("B1:B" & _
Range("B" & Rows.Count).End(xlUp).Row)
If Len(rCell.Text) > 11 Then _
rCell.Value = rCell.Text & "M"
Next rCell
End Sub




.
 
Top