Interpret Cell as it is

AlexanderBB

Well-known Member
Joined
Jul 1, 2009
Messages
1,835
Office Version
  1. 2019
  2. 2016
Platform
  1. Windows
This gets me every time.. looking at the worksheet Cell I see 2:15

But reading Cells(row, Col) in VBA results in 0.09375. I think this is because the cell is formatted to suit a different data type.

Is there a solid way to get "2:15" ? I tried CStr but no change.
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
Here's 2 ways:


Excel 2010
AB
10.093752:15
22:15
Sheet1
Cell Formulas
RangeFormula
B1=HOUR(A1)&":"&MINUTE(A1)
B2=TEXT(A1,"h:mm")


As with all Excel dates, .09375 is the number of days.
 
Last edited:
Upvote 0
Code:
Cells(row, Col).Text
will return the displayed content of the cell as a string.
 
Upvote 0
Thanks very much Rory, I never knew that and it'll be very useful.
Resorted to using Range("F:F").Number Format = "@" but your suggestion is preferred.
 
Upvote 0

Forum statistics

Threads
1,214,642
Messages
6,120,700
Members
448,979
Latest member
DET4492

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