ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Macro to edit time on worksheet (https://www.excelbanter.com/excel-programming/338534-macro-edit-time-worksheet.html)

[email protected]

Macro to edit time on worksheet
 
Hello,

I'm attempting to create a macro that either appends to a time or
converts the value. Basically, I would like the macro to check the
worksheet for times in a particular format, such as:

:34
:45
:21
:00

This format does not allow me to add their values to create a total
time. What I would like to do is create a macro that will check for
values that are in this format, convert them to a 0:mm format (where
'mm' is the value of the time that was in there originally). Thanks for
the help.

Jason


Tom Ogilvy

Macro to edit time on worksheet
 
Sub AA()
For Each cell In Selection
If cell.Text Like ":##" Then
sStr = "0" & cell.Text
cell.NumberFormat = "h:mm"
cell.Value = sStr
End If
Next

End Sub


worked for me.

If you sum up the cells using the sum formula, make sure you format the sum
cell as a Time format.

--
Regards,
Tom Ogilvy



wrote in message
oups.com...
Hello,

I'm attempting to create a macro that either appends to a time or
converts the value. Basically, I would like the macro to check the
worksheet for times in a particular format, such as:

:34
:45
:21
:00

This format does not allow me to add their values to create a total
time. What I would like to do is create a macro that will check for
values that are in this format, convert them to a 0:mm format (where
'mm' is the value of the time that was in there originally). Thanks for
the help.

Jason




jason.banks

Macro to edit time on worksheet
 
Worked like a charm...thanks for your help. Do you know any good sites
for advanced macro tutorials?


Tom Ogilvy

Macro to edit time on worksheet
 
Tutorials, no. But there are plenty of sites with Advanced code.

Go to John Walkenbach's site and look at his links page (and his site as
well)

http://www.j-walk.com/ss/excel

--
Regards,
Tom Ogilvy


"jason.banks" wrote in message
oups.com...
Worked like a charm...thanks for your help. Do you know any good sites
for advanced macro tutorials?





All times are GMT +1. The time now is 04:36 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com