Quick macro help

MOB

Well-known Member
Joined
Oct 18, 2005
Messages
1,066
Office Version
  1. 365
Platform
  1. Windows
A cell contains 12345.56- for example

I want a quick macro that will move the "-" to the front, ie show a proper number -12345.56

How do I do this?

If the cell contains a proper number already eg 123.45 then it should do nothing.

TIA
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
Hi MOB,

Here is an extract from the Excel Help file:

Code:
Convert numbers stored as text to numbers

Note  Some accounting programs display negative values with the negative sign (–) to the right of the value. To convert the text strings to values, you must return all of the characters of the text string except the rightmost character (the negation sign), and then multiply the result by –1. For example, if the value in cell A2 is "156–" the following formula converts the text to the value –156.

Data Formula 
156- =LEFT(A2,LEN(A2)-1)*-1

You would use this basic idea in your macro.
 
Upvote 0
Here it is in a more readable format:

Convert numbers stored as text to numbers

Note Some accounting programs display negative values with the negative sign (–) to the right of the value. To convert the text strings to values, you must return all of the characters of the text string except the rightmost character (the negation sign), and then multiply the result by –1. For example, if the value in cell A2 is "156–" the following formula converts the text to the value –156.

Data Formula
156- =LEFT(A2,LEN(A2)-1)*-1
 
Upvote 0

Forum statistics

Threads
1,224,517
Messages
6,179,233
Members
452,898
Latest member
Capolavoro009

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