Display value as text not in date format

joand

Board Regular
Joined
Sep 18, 2003
Messages
245
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
 

Some videos you may like

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.

BrianB

Well-known Member
Joined
Feb 17, 2003
Messages
8,127
Try ................

Code:
    .Value = "'" & .Text

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

Watch MrExcel Video

Forum statistics

Threads
1,122,519
Messages
5,596,635
Members
414,083
Latest member
Mrsash

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
Top