Cell value vs displayed text

haibiz9

New Member
Joined
Sep 17, 2012
Messages
15
Hello Excel masters,

I'm struggling to get a cell content to display correctly using macros. The cell content is =--7-31 and the displayed text is -24. How do I get it to display --7-31? The equal sign in front throws it off. I've tried all the popular string manipulation functions to no avail. Any help is greatly appreciated.

Other examples:

=--7-31 is currently displayed as -24 while I'd like Excel to show --7-31
=--3-29 is currently displayed as -26 while I'd like Excel to show --3-29
=--10-30 is currently displayed as -20 while I'd like Excel to show --10-30
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
Hi

I don't understand why you have the equal sign in the cell. Why

=--7-31

if you don't want the equal?

You can use the equal sign, if you use a text constant, like

="--7-31"

but, as I said, I don't know why you are using the equal sign.

Another way, is to format the cell as Text and then enter:

--7-31

Again, no equal sign.

Please comment.
 
Upvote 0
Hi pgc01, Thank you for your reply. I really appreciate it. The cell content with the equal sign is imported from another program so I have no control over it. My job is to use macros to format the cell content so that it looks correct. Please let me know if you know a trick to get this done. Thank you.
 
Upvote 0
Hello Smitty, I have to write a macro to format the cell content. Handkeying is not an option for me. Please refer to my reply to pgc01 for more info. Thanks.
 
Upvote 0
I've figured out a line of code to solve this problem

ActiveCell.Value = Right(CStr(ActiveCell.Formula), Len(CStr(ActiveCell.Formula)) - 1)

Thank you for your responses.
 
Upvote 0

Forum statistics

Threads
1,214,653
Messages
6,120,752
Members
448,989
Latest member
mariah3

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