Moving "-" From beginning to end.

GreatOffender

Board Regular
Joined
Feb 2, 2015
Messages
53
I have posted this on another board but I am now on a time crunch so I am grasping at straws. I would use a formula but this is something that will be used again and again by persons other than myself. I need to move the "-" from the end of the number to the beginning. I have cobbled together bits and pieces from other boards/threads and my final result lacks a "trim" which I cannot get to work successfully. The end result is always the same "--" in the front.

Any and all help is always appreciated.

Code:
Sub Fix_Minus_Sign()For Each cell In Range("BE1:BE" & Cells.End(xlDown).Row)
If InStr(1, cell.Value, "-") Then
cell.Value = "-" & Left(cell.Value, Len(cell.Value) - 1)
End If
Next
End Sub
 

Some videos you may like

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.

DataBlake

Well-known Member
Joined
Jan 26, 2015
Messages
781
Office Version
  1. 2016
Platform
  1. Windows
this worked for me? I changed the range to A1:A2
i put "abc-" in A1
and "adv-" in A2

it change to "-abc" and "-adv"

are there instances where "-" appears more than once? or appears somewhere thats not the end?
can you supply an example?
 
Last edited:

DataBlake

Well-known Member
Joined
Jan 26, 2015
Messages
781
Office Version
  1. 2016
Platform
  1. Windows
AHHH its probably formatted as a number try this

Code:
Sub Fix_Minus_Sign()
Range("BE1:BE" & Cells.End(xlDown).Row).NumberFormat = "@"

For Each cell In Range("BE1:BE" & Cells.End(xlDown).Row)
If InStr(1, cell.Value, "-") Then
cell.Value = "-" & Left(cell.Value, Len(cell.Value) - 1)
End If
Next

End Sub
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
53,109
Office Version
  1. 365
Platform
  1. Windows
You haven't been "Fluff"ed out. I was simply asking you to provide the link, so please do that.
 

Watch MrExcel Video

Forum statistics

Threads
1,122,893
Messages
5,598,712
Members
414,254
Latest member
MarieCo

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