#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default minus sign

when importing a file from bus obs i get a column of data where the minus
sign for negative numbers only comes after the last character,( 435-) can
anyone supply me with a function to move the minus sign to the beginning
(-435).

Thanks once again everyone.
--
delmac
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default minus sign

Sub moveminus()
For Each c In range("a2:a22")'Selection
c.Value = "-" & Left(c, Len(c) - 1)

Next
End Sub

--
Don Guillett
SalesAid Software

"delmac" wrote in message
...
when importing a file from bus obs i get a column of data where the minus
sign for negative numbers only comes after the last character,( 435-) can
anyone supply me with a function to move the minus sign to the beginning
(-435).

Thanks once again everyone.
--
delmac



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,726
Default minus sign

Function FormatCells()
Dim cell As Range
For Each cell In Selection
If Right(cell.Value, 1) = "-" Then
cell.Value = Val("-" & Left(cell.Value, Len(cell.Value) - 1))
End If
Next cell

End Function



--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)



"delmac" wrote in message
...
when importing a file from bus obs i get a column of data where the minus
sign for negative numbers only comes after the last character,( 435-) can
anyone supply me with a function to move the minus sign to the beginning
(-435).

Thanks once again everyone.
--
delmac



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,071
Default minus sign

What kind of file is the one you are importing?

I did a few quick tests with XL2003 and a text file.

When you open the file, XL automatically initiates the Text Import wizard.
In step 3, select the column that can contain trailing minus signs, click the
Advanced button and ensure 'Trailing minus for negative numbers' is checked.

If you want to do the same programmatically, record a macro while opening
the file through the UI. A sample result would be (watch out for line wraps):

Workbooks.OpenText Filename:= _
"C:\Temp\Book3.txt", Origin:=437, _
StartRow:=1, DataType:=xlDelimited, TextQualifier:=xlDoubleQuote, _
ConsecutiveDelimiter:=False, Tab:=True, Semicolon:=False,
Comma:=False _
, Space:=False, Other:=False, FieldInfo:=Array(Array(1, 1), Array(2,
1)), _
TrailingMinusNumbers:=True

--

Tushar Mehta
http://www.tushar-mehta.com
Custom business solutions leveraging a multi-disciplinary approach
In Excel 2007 double-click to format may not work; right click and select
from the menu


"delmac" wrote:

when importing a file from bus obs i get a column of data where the minus
sign for negative numbers only comes after the last character,( 435-) can
anyone supply me with a function to move the minus sign to the beginning
(-435).

Thanks once again everyone.
--
delmac

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
Minus Sign JLMcCabes Excel Discussion (Misc queries) 1 March 30th 11 01:34 PM
I do not want the minus sign Steved Excel Worksheet Functions 5 December 8th 08 09:26 PM
minus sign tom mcdonald Excel Worksheet Functions 1 April 19th 06 09:58 AM
plus and minus sign in cells ivoryhunter Excel Worksheet Functions 3 April 10th 06 01:28 PM
I want to display the minus sign ED New Users to Excel 7 October 27th 05 10:06 PM


All times are GMT +1. The time now is 05:11 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"