+ Reply to Thread
Results 1 to 3 of 3

excel macro to move minus sign

  1. #1
    steve1961
    Guest

    excel macro to move minus sign

    I am importing numbers that has the minus sign to the right of the number. I
    need a macro that can move the minus sign to the right of the number. I used
    to have one but must have copied in incorrectly. What I has so far is..
    Sub move_minus_left()
    Dim currentcell As Object
    For Each currentcell In Selection
    If Right (currentcell.Value, 1)="-" Then
    currentcell.formula="-"&left.

    I really really need help with this as soon as possible. Thank you Very Much!

  2. #2
    Wolf
    Guest

    RE: excel macro to move minus sign

    This macro converts text with a minus at the end to a number
    (I think it's from Bill Manville)

    Sub FixNeg()
    Dim C As Range
    For Each C In ActiveSheet.UsedRange.SpecialCells(xlConstants, xlTextValues)
    If Right(C.Value, 1) = "-" Then
    If IsNumeric(Left(C.Value, Len(C.Value) - 1)) Then
    If C.NumberFormat = "@" Then C.NumberFormat = "General"
    C.Value = -CDbl(Left(C.Value, Len(C.Value) - 1))
    End If
    End If
    Next
    End Sub

    Wolf


    "steve1961" wrote:

    > I am importing numbers that has the minus sign to the right of the number. I
    > need a macro that can move the minus sign to the right of the number. I used
    > to have one but must have copied in incorrectly. What I has so far is..
    > Sub move_minus_left()
    > Dim currentcell As Object
    > For Each currentcell In Selection
    > If Right (currentcell.Value, 1)="-" Then
    > currentcell.formula="-"&left.
    >
    > I really really need help with this as soon as possible. Thank you Very Much!


  3. #3
    Don Guillett
    Guest

    Re: excel macro to move minus sign

    try this instead
    Sub move_minus_left()
    For Each c In Selection
    If Right(c, 1) = "-" Then _
    c.Value = "-" & Left(c, (Len(c) - 1))
    Next
    End Sub

    --
    Don Guillett
    SalesAid Software
    donaldb@281.com
    "steve1961" <steve1961@discussions.microsoft.com> wrote in message
    news:EA447646-D220-4D31-BFF9-0885E79D4AFC@microsoft.com...
    > I am importing numbers that has the minus sign to the right of the number.

    I
    > need a macro that can move the minus sign to the right of the number. I

    used
    > to have one but must have copied in incorrectly. What I has so far is..
    > Sub move_minus_left()
    > Dim currentcell As Object
    > For Each currentcell In Selection
    > If Right (currentcell.Value, 1)="-" Then
    > currentcell.formula="-"&left.
    >
    > I really really need help with this as soon as possible. Thank you Very

    Much!



+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1