Solved

excel format number

Posted on 2008-10-04
1
212 Views
Last Modified: 2012-05-05
For some reason I have a column and the positive/negative sign follows the number like 10.22+ or 45.55-.

Excel does not recognize this as a number.  How can I get the + or - before the number instead of after it?

I tried selecting everything, and formatting, but that did not work.
0
Comment
Question by:jackjohnson44
1 Comment
 
LVL 81

Accepted Solution

by:
zorvek (Kevin Jones) earned 500 total points
ID: 22641669
You're going to need a little macro help. The routines below convert negative numeric values with trailing negative signs (e.g., "123-") into numeric values. When entering or importing such values Excel interprets them as text instead of numeric values.

Select the cells to convert and run the macro ConvertTrailingNegativeValuesDefault.

[Begin Code Segment]

Public Sub ConvertTrailingNegativeValuesDefault()

' Call the routine ConvertTrailingNegativeValues using the current selection.

   ConvertTrailingNegativeValues Selection
   
End Sub


Public Sub ConvertTrailingNegativeValues( _
      ByVal Target As Range _
   )

' Convert any numeric values with trailing negative signs to numeric values.
'
' Syntax
'
' ConvertTrailingNegativeValues(Target)
'
' Target - The range containing the values to convert.

   Dim Cell As Range

   For Each Cell In Target
      If Len(Cell) > 1 Then
         If VarType(Cell) = vbString Then
            If Right(Cell, 1) = "-" And IsNumeric(Left(Cell, Len(Cell) - 1)) Then
               Cell = CDbl(Cell)
            End If
         End If
      End If
   Next Cell

End Sub

[End Code Segment]

Kevin
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question