Vba to insert time in cell with text

  • Re: Vba to insert time in cell with text


    Maybe:

    Code
    Sub InsertTime()
        Range("A1") = Range("A1") & " " & Time
    End Sub

    You can say "THANK YOU" for help received by clicking the :thumbup: icon in the bottom right corner of the helper's post.
    Practice makes perfect. I am very far from perfect so I'm still practising.

  • Re: Vba to insert time in cell with text


    You can align the entire cell to the right but I'm not sure if you can align part of the cell contents to the right. You can force the time further to the right by adding spaces between the quotes in the code. I don't know if this would work for you.

    You can say "THANK YOU" for help received by clicking the :thumbup: icon in the bottom right corner of the helper's post.
    Practice makes perfect. I am very far from perfect so I'm still practising.

  • Re: Vba to insert time in cell with text


    That did the trick Mumps, what if I wanted Date instead with a certain format.


    Code
    Range("A1") = Range("A1") & " " & Date  this works but can't make it format the way I need.
    want the date to show like 2-21-2015  tried custom format on cell but it will not listen. LOL
  • Re: Vba to insert time in cell with text


    Try:

    Code
    Sub InsertDate()
        Range("A1") = Range("A1") & " " & Format(Date, "mm-dd-yyyy")
    End Sub

    You can say "THANK YOU" for help received by clicking the :thumbup: icon in the bottom right corner of the helper's post.
    Practice makes perfect. I am very far from perfect so I'm still practising.

  • Re: Vba to insert time in cell with text


    My pleasure. :)

    You can say "THANK YOU" for help received by clicking the :thumbup: icon in the bottom right corner of the helper's post.
    Practice makes perfect. I am very far from perfect so I'm still practising.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!