Formatted cell shows incorrect information

Denny57

Board Regular
Joined
Nov 23, 2015
Messages
185
Office Version
  1. 365
Platform
  1. Windows
I have custom formatted a range of cells as hh:mm but when I key information (eg 1234) I get the result 00:00, whilst the formula bar shows 18/05/1903 00:00:00. I assume that 1234 relates to the number of days from the first date coded into Excel.

Is this the correct result, in which case what is the point of formatting if the entered information will not display as expected?

Alternatively, is there some VBA code that can be applied to the range in the worksheet to convert 1234 to text value 12:34?
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
Additional Information
Details in this range are to be used as a unique detail to undertake a search and recall records via a User Form.
I could create additional controls to add this detail but this would make my process more "clumsy" as it is actually easier to key initial information (including time) into cells in a worksheet.
The file is not for storing information but to be used as a tool which will be cleared daily. Therefore the "time" information in the worksheet needs to be in a format that can be recognised in the user form search.
 
Upvote 0
I have custom formatted a range of cells as hh:mm but when I key information (eg 1234) I get the result 00:00, whilst the formula bar shows 18/05/1903 00:00:00. I assume that 1234 relates to the number of days from the first date coded into Excel.

Is this the correct result, in which case what is the point of formatting if the entered information will not display as expected?

Alternatively, is there some VBA code that can be applied to the range in the worksheet to convert 1234 to text value 12:34?

Hi,

I had the same problem as you.

You need to type 12:34 instead of 1234 and it will work display information correctly.

It feels stupid, but I had the same problem, that's why I know the "solution".

I'm sure that you can build a macro to take 1234 and change it to 12:34.

Can´t understand why a properly formated cell does not work, but it's excel's way
 
Upvote 0
The reason is because of the way excel handles dates and times. Dates are Integers so 1234 is a perfectly reasonable date. Time on the other hand is a proportion of a day, so 12hrs = 0.5. This means you have to be explicit about whether you're entering a time or a date. Adding the colon as correctly suggested above informs excel that 12:34 is a time not a date. One way to see what is happening is to type 12:34 into a cell and then format it as 'General' you will then see the value change to 0.5236111...

HTH
 
Upvote 0
Hi,

I had the same problem as you.

You need to type 12:34 instead of 1234 and it will work display information correctly.

It feels stupid, but I had the same problem, that's why I know the "solution".

I'm sure that you can build a macro to take 1234 and change it to 12:34.

Can´t understand why a properly formated cell does not work, but it's excel's way
Thank you, I have VBA code which converts a 4 digit number to nn:nn by splitting it into 2 x 2 and inserting the colon. Unfortunately this is specific to a textbox and I am having a problem applying this to a range of cells in a worksheet awhes the number is entered. I have created a small user form to add records in the meantime.
 
Upvote 0

Forum statistics

Threads
1,215,474
Messages
6,125,023
Members
449,203
Latest member
tungnmqn90

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