#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Move Dash

We are outputing data (in csv format) from an AS400 accounting packing that
is to be imported in to Excel for the auditors. The RPG language in the AS400
reads/displays negative numbers with the dash on the rights side of the
number (123-) rather than the leading dash (-123) that we normally use in the
world.
Any tips for writting a module that will search thru range A1:A100 and move
the dash from the right to the left (or replace the right dash with brackets
on each side of the number? Can seem to get it right.
Thanks
Rick
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,339
Default Move Dash

Hi,
You could use following- add a working column (B) and insert the
following and copy down

=IF(RIGHT(A1,1)="-",("-" &LEFT(A1,LEN(A1)-1))*1,A1)

With VBA:

Sub ConvertAS400()
Dim i As Integer
For i = 1 To 100
If Right(Range("a" & i), 1) = "-" Then
Range("A" & i) = ("-" & Left(Range("a" & i), Len(Range("a" & i)) - 1) * 1)
End If
Next i
End Sub
HTH

"Rick K" wrote:

We are outputing data (in csv format) from an AS400 accounting packing that
is to be imported in to Excel for the auditors. The RPG language in the AS400
reads/displays negative numbers with the dash on the rights side of the
number (123-) rather than the leading dash (-123) that we normally use in the
world.
Any tips for writting a module that will search thru range A1:A100 and move
the dash from the right to the left (or replace the right dash with brackets
on each side of the number? Can seem to get it right.
Thanks
Rick

  #3   Report Post  
Posted to microsoft.public.excel.programming
ben ben is offline
external usenet poster
 
Posts: 232
Default Move Dash

sub replace
dim cel as range
for each cel in activesheet.range("A1:A100")
if right(cel,1) = "-" then
cel = "-"+left(cel,len(cel)-1)
end if
next
end sub

untested but it should get you started
--
When you lose your mind, you free your life.


"Rick K" wrote:

We are outputing data (in csv format) from an AS400 accounting packing that
is to be imported in to Excel for the auditors. The RPG language in the AS400
reads/displays negative numbers with the dash on the rights side of the
number (123-) rather than the leading dash (-123) that we normally use in the
world.
Any tips for writting a module that will search thru range A1:A100 and move
the dash from the right to the left (or replace the right dash with brackets
on each side of the number? Can seem to get it right.
Thanks
Rick

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Move Dash

Thanks everyone, I'll try all solutions you've provided
Rick

"Rick K" wrote:

We are outputing data (in csv format) from an AS400 accounting packing that
is to be imported in to Excel for the auditors. The RPG language in the AS400
reads/displays negative numbers with the dash on the rights side of the
number (123-) rather than the leading dash (-123) that we normally use in the
world.
Any tips for writting a module that will search thru range A1:A100 and move
the dash from the right to the left (or replace the right dash with brackets
on each side of the number? Can seem to get it right.
Thanks
Rick

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Move Dash


Rick,
Give this a try.

Sub Fix_Dash()
Dim n As Integer, Cell_Value As String, Cell_Temp As String, Dash_Place
As Integer

For n = 1 To 1000

Cell_Value = Range("A" & n).Value
Dash_Place = InStr(1, Cell_Value, "-")

If Dash_Place 0 Then
Cell_Temp = "-" & Left(Cell_Value, Dash_Place - 1)
Range("A" & n).Value = Cell_Temp
End If

Next

End Sub


--
Peter81
------------------------------------------------------------------------
Peter81's Profile: http://www.excelforum.com/member.php...o&userid=25353
View this thread: http://www.excelforum.com/showthread...hreadid=388345



  #6   Report Post  
Posted to microsoft.public.excel.programming
ben ben is offline
external usenet poster
 
Posts: 232
Default Move Dash

in normal practice of course i shouldn't have named the sub replace

--
When you lose your mind, you free your life.


"ben" wrote:

sub replace
dim cel as range
for each cel in activesheet.range("A1:A100")
if right(cel,1) = "-" then
cel = "-"+left(cel,len(cel)-1)
end if
next
end sub

untested but it should get you started
--
When you lose your mind, you free your life.


"Rick K" wrote:

We are outputing data (in csv format) from an AS400 accounting packing that
is to be imported in to Excel for the auditors. The RPG language in the AS400
reads/displays negative numbers with the dash on the rights side of the
number (123-) rather than the leading dash (-123) that we normally use in the
world.
Any tips for writting a module that will search thru range A1:A100 and move
the dash from the right to the left (or replace the right dash with brackets
on each side of the number? Can seem to get it right.
Thanks
Rick

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
Dash Ports Twila Excel Worksheet Functions 1 August 21st 07 11:00 PM
dash showtunegirl Excel Worksheet Functions 3 October 4th 06 02:00 PM
adding a dash A.S. Excel Discussion (Misc queries) 1 September 12th 06 10:27 PM
Dash in format Mpls501sMan Excel Discussion (Misc queries) 4 April 25th 06 12:36 PM
understanding dash dash in a excel formula ldebner Excel Worksheet Functions 2 October 31st 05 01:47 PM


All times are GMT +1. The time now is 05:21 AM.

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"