0

I have a report and in columns L to Y I have the time of hh:mm:ss written as text and as a result I'm unable to do pivot calculations.

Is there an excel vba script that I can use to convert columns L:Y to the time value of hh:mm:ss?

any help would be appreciated.

Thanks

7
  • stackoverflow.com/questions/20375233/… Commented Jul 30, 2016 at 0:40
  • You can copy the dates and paste them in Notepad, then copy the text from Notepad and paste in Excel. Commented Jul 30, 2016 at 1:52
  • Thanks slai, doing that works however I think it is impractical to be doing this each time the report is generated. Was hoping for something more automated. Commented Jul 30, 2016 at 2:08
  • 3
    Clipboard copy and paste can be automated with MSForms.DataObject. Anyway, you can try something like [L1:Y2].Value = [L1:Y2*1] Commented Jul 30, 2016 at 2:59
  • Thanks Slai that works for me, much appreciated Commented Jul 30, 2016 at 3:29

2 Answers 2

1

A bit late, but another similar solution is to copy a blank cell and add it to the range with Paste Special

or better, change the format and copy the values like this:

Set r = Intersect(UsedRange, Range("L:Y"))  ' only the used range in columns L to Y
r.NumberFormat = "HH:mm:ss"    ' military time format 24:59:59 ?
r.Value2 = r.Value2
Sign up to request clarification or add additional context in comments.

Comments

0

Without using VBA, you could perhaps put a formula in columns Z onwards, e.g. Z2's formula could say =TIMEVALUE(L2) etc.

Using VBA, you could use either the CDate or TimeValue functions to convert the string to a date/time.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.