Solved

excel format number

Posted on 2008-10-04
1
210 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
Improved? Move/Copy Add-in Replacement - How to avoid the annoying, “A formula or sheet you want to move or copy contains the name XXX, which already exists on the destination worksheet.” David Miller (dlmille)  It was one of those days… I wa…
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
Learn how to make your own table of contents in Microsoft Word using paragraph styles and the automatic table of contents tool. We'll be using the paragraph styles in Word’s Home toolbar to help you create a table of contents. Type out your initial …

760 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now