Divide values, VBA

Desu Nota from Columbus

Well-known Member
Joined
Mar 17, 2011
Messages
556
I have a column (E) of data that is in seconds. I need a code to put in my macro that converts it into hh:mm:ss.

I can divide the numbers by 86400 (60*60*24) and then format to [h]:mm:ss and they work, but I haven't been able to get a macro to do it.

how should I change this code?

Code:
Range("E2:E65534").FormulaR1C1 = "=IF(RC[0]="""","""",RC[0]/86400"
Columns("E:E").NumberFormat = "[h]:mm:ss"
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
That looks like it should work. What result do you get?

The values are only changing format, the division is never taking place.

I am headed out of the office for the day now, but I will be back first thing in the morning.

I am trying to avoid using a recorded macro where I copy/paste special > Divide 86400, down the entire column

I want to know how to do this using a more universal method if possible.
 
Last edited:
Upvote 0
If your "seconds" data is in column E, aren't you overwriting your data with a formula?

How about PasteSpecial?

Gary

Code:
Range("F2").Value = 86400 'Some unused cell
Range("F2").Copy
Range("E2:E65534").PasteSpecial xlPasteValues, xlPasteSpecialOperationDivide
 
Upvote 0

Forum statistics

Threads
1,224,518
Messages
6,179,248
Members
452,900
Latest member
LisaGo

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top