Interpret Cell as it is

AlexanderBB

Well-known Member
Joined
Jul 1, 2009
Messages
2,072
Office Version
  1. 2019
  2. 2010
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

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
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,223,908
Messages
6,175,305
Members
452,633
Latest member
DougMo

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