Display value as text not in date format

joand

Active Member
Joined
Sep 18, 2003
Messages
266
I have a code (see below) that extracts a specific string from column A. The problem with this is that it outputs the string in date format. In this case, the output should be "3/5". When I execute the code, it outputs as a date "5-Mar". I tried to change the format of the cell to "Fraction" but the problem is that instead of outputting "3/5", it results to a "0.6" value although it is displayed as "3/5". When I changed the format to "Text", instead of outputting a value, the resulting formula is displayed. I need the output to be displayed as "3/5" (text)

Any ideas?

Code:
With ActiveSheet.Range("A2", Cells(Rows.Count, "A").End(xlUp)).Offset(0, 7)
    .Formula = "=IF(ISERROR(LEFT(MID(RC1,FIND(""<""&R1C&"">"",RC1)+6,LEN(RC1)),FIND(""</""&R1C&"">"",MID(RC1,FIND(""<""&R1C&"">"",RC1)+6,LEN(RC1)))-1)),"""",LEFT(MID(RC1,FIND(""<""&R1C&"">"",RC1)+6,LEN(RC1)),FIND(""</""&R1C&"">"",MID(RC1,FIND(""<""&R1C&"">"",RC1)+6,LEN(RC1)))-1))"
    .Value = .Value
End With
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
Try ................

Code:
    .Value = "'" & .Text

The ' apostrophe (on keyboard with @) ( inside quotes "") forces the cell contents to text.
 
Upvote 0

Forum statistics

Threads
1,214,960
Messages
6,122,479
Members
449,088
Latest member
Melvetica

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