Moving "-" From beginning to end.

GreatOffender

Board Regular
Joined
Feb 2, 2015
Messages
56
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
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
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:
Upvote 0
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
 
Upvote 0
You haven't been "Fluff"ed out. I was simply asking you to provide the link, so please do that.
 
Upvote 0

Forum statistics

Threads
1,223,164
Messages
6,170,444
Members
452,326
Latest member
johnshaji

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