Getting #VALUE! error while calculating time difference

Gautham A

Board Regular
Joined
May 25, 2020
Messages
107
Office Version
  1. 2016
Platform
  1. Windows
Hi Team,

In cell B3, the time is 06:32:09 and in A3 I have 03:34:46. In cell C3,I apply the formula =B3-A3. I should get 02:57:23. But I'm getting #VALUE! error.
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
See how the cell is doing, see if it is as text. I did the same calculation and the result was correct.
 
Upvote 0
I found some thing. Actually for each cell there is a empty space at the end. I removed that manually.Now it is working. Is there any VBA code to remove empty space in the end? Because I have to do the same task for about 200 cells. Thanks in advance
 
Upvote 0
You can actually fix them all at the same time without using VBA.
Just select all the cells, and do a Find/Replace, replacing a single space with nothing.
If you choose the "Replace All" option, it will do all selected cells at once.
 
Upvote 0
I found some thing. Actually for each cell there is a empty space at the end. I removed that manually.Now it is working. Is there any VBA code to remove empty space in the end? Because I have to do the same task for about 200 cells. Thanks in advance

Good morning!

I use the Trim() function to this.

Example: =Trim(B3)-Trim(A3)

But pay attention for the orientations from @Joe4 to you.
 
Upvote 0
Hi Joe and leandroarb
I tried both of your methods but still I'm getting the error
 
Upvote 0
What happens if you run this
VBA Code:
Sub GauthamA()
   ActiveSheet.UsedRange.Replace Chr(160), "", xlPart, , , , False, False
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,706
Messages
6,126,340
Members
449,311
Latest member
accessbob

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