Converting a Number with Minus Sign on Right to Minus on LeftID: Q42964
|
When you import a worksheet into Microsoft Excel and that worksheet contains numbers with minus signs on the right (for example, 12345-), Microsoft Excel may not treat these numbers as negative numbers.
Microsoft Excel treats these numbers as text because the minus sign appears to the right side of the number.
There are two ways to solve this problem:
=IF(RIGHT(A1,1)="-","-"&LEFT(A1,LEN(A1)-1),A1)*1
For example, follow these steps:
A1: 3
A2: 2-
A3: 1-
A4: 4
A5: 6-
Sub move_minus_left()
Dim currentcell As Object
For Each currentcell In Selection
If Right(currentcell.Value, 1) = "-" Then
currentcell.Formula = "-" & Left(currentcell.Value, _
Len(currentcell.Value) - 1)
End If
Next currentcell
End Sub
A1: =FOR.CELL("Current")
A2: =SELECT(Current)
A3: =IF(RIGHT(Current,1)="-",FORMULA("-"&LEFT(Current,LEN(Current)-1)),)
A4: =NEXT()
A5: =RETURN()
A1: Switch Minus Sign
A2: =ACTIVE.CELL()
A3: =IF(RIGHT(A2,1)="-",FORMULA("-"&LEFT(A2,LEN(A2)-1)),)
A4: =RETURN()
Additional query words: 2.0 2.00 2.01 2.1 2.10 2.2 2.20 2.21 3.0 3.00 4.0 4.00 4.0a 4.00a 5.0 import mainframe miniframe main mini frame export
Keywords : xlformat
Version : WINDOWS:2.0,3.0,4.0,5.0,5.0c,7.0; MACINTOSH:2.0,3.0,4.0,5.0,98
Platform : MACINTOSH WINDOWS
Issue type : kbprb
Last Reviewed: July 29, 1999