PC Review


Reply
Thread Tools Rate Thread

Change "-" from right first character to left first character to make a negative amount

 
 
amorrison2006@googlemail.com
Guest
Posts: n/a
 
      27th Jul 2007
Hi

I have a column of data.


Unfortunately the negative symbol is on the right of the numbers to
represent a negative number.


What I need is a macro to look down a column and if it find the first
character to the right of that cell is a "-" symbol then move that to
the first character on the left of the cell to make the numbers
negative.


I hope this is possible and someone can help,


Thank you so much in advance,

Andrea

 
Reply With Quote
 
 
 
 
=?Utf-8?B?Um9uIENvZGVycmU=?=
Guest
Posts: n/a
 
      27th Jul 2007
I believe you can use Text-to-Columns if you have Excel 2000 or later.

Try this:

Select the column range of cells to be impacted

From the Excel main menu:
<data><text-to-columns>
.....click [Next] until Step 3 of 3

Click the [Advanced] button
.....Check: "Trailing minus sign for negative numbers"....Click [OK]

Click [Finish]

Does that help?
***********
Regards,
Ron

XL2003, WinXP


"(E-Mail Removed)" wrote:

> Hi
>
> I have a column of data.
>
>
> Unfortunately the negative symbol is on the right of the numbers to
> represent a negative number.
>
>
> What I need is a macro to look down a column and if it find the first
> character to the right of that cell is a "-" symbol then move that to
> the first character on the left of the cell to make the numbers
> negative.
>
>
> I hope this is possible and someone can help,
>
>
> Thank you so much in advance,
>
> Andrea
>
>

 
Reply With Quote
 
=?Utf-8?B?WFA=?=
Guest
Posts: n/a
 
      27th Jul 2007

Here is one VBA solution that ignores values unless they contain a dash
(minus
sign). Using this method, you need to make your selection first, then run.
Watch for line wrapping:

Dim lDash As Long
Dim sValue As String
Dim rCell As Range
For Each rCell In Selection
If InStr(1, rCell.FormulaR1C1, "-", vbTextCompare) <> 0 Then
lDash = InStr(1, rCell.FormulaR1C1, "-", vbTextCompare)
sValue = Application.WorksheetFunction.Replace(rCell.FormulaR1C1,
lDash, 1, "")
rCell.FormulaR1C1 = "-" & sValue
End If
Next rCell

HTH

"(E-Mail Removed)" wrote:

> Hi
>
> I have a column of data.
>
>
> Unfortunately the negative symbol is on the right of the numbers to
> represent a negative number.
>
>
> What I need is a macro to look down a column and if it find the first
> character to the right of that cell is a "-" symbol then move that to
> the first character on the left of the cell to make the numbers
> negative.
>
>
> I hope this is possible and someone can help,
>
>
> Thank you so much in advance,
>
> Andrea
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
If 5th character="-" delete everything to the left otherwise do no Mike R. Microsoft Excel Worksheet Functions 6 12th Nov 2008 10:00 PM
how to replace "enter character" with "space character" in msword =?Utf-8?B?TVMtV29yZA==?= Microsoft Word Document Management 1 19th Dec 2006 05:26 AM
Make the em dash a "break" character for text selection =?Utf-8?B?SmltSCAoRk0p?= Microsoft Word Document Management 0 28th Jun 2006 05:35 PM
Change dollar amount to a negative if another colum has a "P" =?Utf-8?B?TWFydmlu?= Microsoft Excel Programming 2 27th Sep 2005 03:25 AM
Character "W" is cut off on the left on a Radion 7000. Bruce K. ATI Video Cards 5 10th Apr 2004 06:49 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:53 AM.