Time to Decimal conversion with embedded formula

Christiann

New Member
Joined
Nov 18, 2020
Messages
2
Office Version
  1. 2010
Platform
  1. Windows
Hello Smart People! I have a situation with converting time from a timecard to decimal form in a spreadsheet.

Here's how far I've gotten: I know the formula to convert the clocked time (4:30) to decimal (4.5).

What I don't know how to do is to embed that formula in each cell so that when I type in the clocked time (4:30) the cell is automatically changed to the decimal (4.5). I don't want to create separate columns where i put in the clocked time because then I have to hide all of the raw data when sending in the spreadsheet electronically.

Any help would be amazing! Thank you!
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
You can't. The only way to do what you describe in the same cell is to use a macro.

Put this code into the module for the worksheet containing your data. This assumes that anything in column A is a time. As soon as the user types it in, it is converted from time value to decimal hours (i.e., multiplied by 24).

VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)

   If Target.Column = 1 Then
   
      Application.EnableEvents = False
      Target = Target * 24
      Target.NumberFormat = "General"
      
      Application.EnableEvents = True
      
   
   End If

End Sub
 
Upvote 0
This got me very close. Here's what I'm running into and can't fix: When I type in 4:30 into a cell, the macro is converting the time to just 0.19 for some reason, when it should be converting to 4.5.
 
Upvote 0

Forum statistics

Threads
1,213,486
Messages
6,113,932
Members
448,533
Latest member
thietbibeboiwasaco

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