Macro for editing a series of cells

L

Laddie

I am trying have a macro edit a series of cells automatically. Each cell is
the same format but has different information.

Basically I am trying to take a cell with a format of 0100 AM and have this
changed to 01:00 AM.

There is a large range of these cells thus the reason for wanting to
automate the insert of the colon.
 
G

Gary''s Student

If the values are genuine times, you can just change the format. If not,
select the cells and run this small macro:

Sub colonize()
For Each r In Selection
v = r.Text
r.Clear
r.NumberFormat = "@"
r.Value = Left(v, 2) & ":" & Right(v, 5)
Next
End Sub
 
L

Laddie

Gary -

Thank you very much, it works like a charm...perfectly. I am far from a
programmer but have always been able to fight my way through Excel issues in
the past but this was one which was driving me crazy.

Can't thank you enough.... I owe you a beer.
 

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

Top