Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11
Default Delete "CR" at the end of a number and make the # negative?

The program I am using is placing a "CR" at the end of every negative
number to denote that it is a "credit". This poses a problem when
using the data, as Excel won't recognize the number. I need to get/
write a macro that deletes the "CR" and makes the number negative. I
tried the "Left" commands in excel, but it won't work since you have
to specify how many numbers numbers are to the left and that changes
depending on the size of the number. Any ideas?

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 208
Default Delete "CR" at the end of a number and make the # negative?

try this
=if(exact(Right(a1,2),"CR"),value(left(a1,len(a1)-2)*-1),a1)

On Aug 15, 5:32 pm, wrote:
The program I am using is placing a "CR" at the end of every negative
number to denote that it is a "credit". This poses a problem when
using the data, as Excel won't recognize the number. I need to get/
write a macro that deletes the "CR" and makes the number negative. I
tried the "Left" commands in excel, but it won't work since you have
to specify how many numbers numbers are to the left and that changes
depending on the size of the number. Any ideas?



  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 698
Default Delete "CR" at the end of a number and make the # negative?

You may not really need a macro for this...

Assuming the "numbers" end with " CR"(a space followed by CR)

Try this:
Select the range to be impacted

Then...From the Excel main menu:
<edit<replace
Find what: CR<-----a space followed by CR
Replace with: -
Click [Replace All]

one more step....
<data<text-to-columns
Click [Next] until Step_3_of_3
Check: General
(If you click the [Advanced] button, you'll see that Excel's default is to
convert numbers with trailing minus signs to negative numbers)
Click [Finish]

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

XL2003, WinXP


" wrote:

The program I am using is placing a "CR" at the end of every negative
number to denote that it is a "credit". This poses a problem when
using the data, as Excel won't recognize the number. I need to get/
write a macro that deletes the "CR" and makes the number negative. I
tried the "Left" commands in excel, but it won't work since you have
to specify how many numbers numbers are to the left and that changes
depending on the size of the number. Any ideas?


  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,202
Default Delete "CR" at the end of a number and make the # negative?

Tim has given you a method to do it with a spreadsheet formula coupled with
a help column. However, if you need to physically change the values in their
current cells, then this macros should do that for you (just set the
appropriate range in the For Each statement line)..

Sub RemoveCR()
Dim R As Range
For Each R In Range("A1:A200")
If R.Value Like "*[Cc][Rr]" Then
R.Value = -Left(R.Value, Len(R.Value) - 2)
End If
Next
End Sub

Rick

wrote in message
ps.com...
The program I am using is placing a "CR" at the end of every negative
number to denote that it is a "credit". This poses a problem when
using the data, as Excel won't recognize the number. I need to get/
write a macro that deletes the "CR" and makes the number negative. I
tried the "Left" commands in excel, but it won't work since you have
to specify how many numbers numbers are to the left and that changes
depending on the size of the number. Any ideas?


  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11
Default Delete "CR" at the end of a number and make the # negative?

On Aug 15, 4:47 pm, "Rick Rothstein \(MVP - VB\)"
wrote:
Tim has given you a method to do it with a spreadsheet formula coupled with
a help column. However, if you need to physically change the values in their
current cells, then this macros should do that for you (just set the
appropriate range in the For Each statement line)..

Sub RemoveCR()
Dim R As Range
For Each R In Range("A1:A200")
If R.Value Like "*[Cc][Rr]" Then
R.Value = -Left(R.Value, Len(R.Value) - 2)
End If
Next
End Sub

Rick

wrote in message

ps.com...



The program I am using is placing a "CR" at the end of every negative
number to denote that it is a "credit". This poses a problem when
using the data, as Excel won't recognize the number. I need to get/
write a macro that deletes the "CR" and makes the number negative. I
tried the "Left" commands in excel, but it won't work since you have
to specify how many numbers numbers are to the left and that changes
depending on the size of the number. Any ideas?- Hide quoted text -


- Show quoted text -


I used this, and tried to add the ActieSheet command to apply to
multiple worksheets, but its not working for me. I've looked at the
code several times. Ideas?



  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22,906
Default Delete "CR" at the end of a number and make the # negative?

The code will run on any sheet that is active.

Do you want to run it on multiple selected sheets or all sheets in the workbook?

Sub RemoveCR()
Dim R As Range
Dim ws As Worksheet
For Each ws In ActiveWorkbook.Sheets
'If only some sheets are selected change the above line to
'For each ws in ActiveWindow.SelectedSheets
For Each R In ws.Range("A1:A200")
If R.Value Like "*[Cc][Rr]" Then
R.Value = -Left(R.Value, Len(R.Value) - 2)
End If
Next R
Next ws
End Sub


Gord Dibben MS Excel MVP

On Thu, 16 Aug 2007 08:42:00 -0700, wrote:

On Aug 15, 4:47 pm, "Rick Rothstein \(MVP - VB\)"
wrote:
Tim has given you a method to do it with a spreadsheet formula coupled with
a help column. However, if you need to physically change the values in their
current cells, then this macros should do that for you (just set the
appropriate range in the For Each statement line)..

Sub RemoveCR()
Dim R As Range
For Each R In Range("A1:A200")
If R.Value Like "*[Cc][Rr]" Then
R.Value = -Left(R.Value, Len(R.Value) - 2)
End If
Next
End Sub

Rick

wrote in message

ps.com...



The program I am using is placing a "CR" at the end of every negative
number to denote that it is a "credit". This poses a problem when
using the data, as Excel won't recognize the number. I need to get/
write a macro that deletes the "CR" and makes the number negative. I
tried the "Left" commands in excel, but it won't work since you have
to specify how many numbers numbers are to the left and that changes
depending on the size of the number. Any ideas?- Hide quoted text -


- Show quoted text -


I used this, and tried to add the ActieSheet command to apply to
multiple worksheets, but its not working for me. I've looked at the
code several times. Ideas?


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Delete the number "49" from each cell in a column se12 Excel Worksheet Functions 18 September 5th 06 05:53 PM
make "F51668H200AU" into "F5166-8H200AU" fitzu Excel Discussion (Misc queries) 6 August 11th 06 11:46 PM
Make "Edit" mode default, rather than "Enter"? Greg Boettcher Excel Discussion (Misc queries) 1 July 27th 06 01:46 AM
How to make number of "static" fields stay the same when copying? MrHaugen Excel Discussion (Misc queries) 2 July 11th 06 08:40 PM
how can I make an excel cell "mark" or "unmark" when clicked on? Rick Excel Discussion (Misc queries) 6 January 8th 06 10:15 PM


All times are GMT +1. The time now is 08:43 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"