Announcement

Collapse
No announcement yet.

Unconfigured Ad Widget

Collapse

Inserting a Character into a String (In a Cell)

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Inserting a Character into a String (In a Cell)

    Hello people,
    Slight problem with a Worksheet that I've inhereted,
    All the Time values in the cells have no ":" so I'm seeing times like (All in Military time) 700 of 2200
    How do I put a Colon in the string with VBA,
    I know about using the LEN to see where I would need to put it.. but thats as far as I can go..
    Any Advice will be to my sincearest appreciation..
    Thank you

  • #2
    Re: Inserting a Character into a String (In a Cell)

    If you just want to keep it as a string rather than convert it to Excel time use
    =LEFT(A1,LEN(A1)-2)&":"&RIGHT(A1,2)
    Please do not U2U (private message) me directly for questions that should be posted to the forum; any such U2Us will be ignored.

    Comment


    • #3
      Re: Inserting a Character into a String (In a Cell)

      What about VBA?
      can I do a code for that?

      Thanks

      Comment


      • #4
        Re: Inserting a Character into a String (In a Cell)

        VBA version of Derk's formula
        Code:
        Sub AddColon()
            Dim rngTemp As Range
            
            For Each rngTemp In Selection.Cells
                rngTemp = Left(rngTemp, Len(rngTemp) - 2) & ":" & Right(rngTemp, 2)
            Next
        End Sub

        Cheers
        Andy

        Comment

        Trending

        Collapse

        There are no results that meet this criteria.

        Working...
        X