macro to add alpha character to cell contents

  • Thread starter Thread starter Janna
  • Start date Start date
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.
 
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
 
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




.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top