+ Reply to Thread
Results 1 to 10 of 10

minus sign

  1. #1
    Forum Contributor
    Join Date
    08-10-2006
    Posts
    723

    minus sign

    hi,

    i run a macro that gets data from a mainframe and put it into exel. there are 3 columns where the data has a qty in them
    i put this data then into a pivot table . the problem i have is that the minus numbers come down as follows

    300- etc

    in the macro i would like to put some code that will change any number with the - at the back to teh frony of the number
    ie -300

    thanks

    steve

  2. #2
    Forum Expert Carim's Avatar
    Join Date
    04-07-2006
    Posts
    4,070
    Hi,

    Formula would be

    Please Login or Register  to view this content.
    HTH
    Carim

  3. #3
    Forum Contributor
    Join Date
    07-13-2006
    Posts
    400
    something like

    Sub something()
    Dim LookRange As Range
    Dim Item As Range

    Set LookRange = Range("A1:A100") 'set the range you want to search

    For Each Item In LookRange
    If Mid(Item, Len(Item), 1) = "-" Then
    Item = "-" & Mid(Item, 1, Len(Item) - 1)
    End If
    Next

    End Sub
    --Mark

    Quantum materiae materietur marmota monax si marmota monax materiam possit materiari?

  4. #4
    Forum Contributor
    Join Date
    08-10-2006
    Posts
    723
    hi,
    thanks both



    this code changes as needed but it errors at the end with the if mid (item line


    Please Login or Register  to view this content.


    steve

  5. #5
    Forum Expert Carim's Avatar
    Join Date
    04-07-2006
    Posts
    4,070
    Hi,

    Just tested one cell ...

    Please Login or Register  to view this content.
    HTH
    Carim

  6. #6
    Forum Contributor
    Join Date
    07-13-2006
    Posts
    400
    what version of excel do you have

    and what kind of error did it give you?

    i think the problem might be that you're looking in a blank cell.

    Sub something()
    Dim LookRange As Range
    Dim Item As Range

    Set LookRange = Range("A1:A100") 'set the range you want to search

    For Each Item In LookRange
    if item=blank then
    goto skiptonext:
    end if
    If Mid(Item, Len(Item), 1) = "-" Then
    Item = "-" & Mid(Item, 1, Len(Item) - 1)
    End If
    skiptonext:
    Next

    End Sub
    Last edited by MDubbelboer; 11-29-2006 at 02:25 PM.

  7. #7
    Forum Contributor
    Join Date
    08-10-2006
    Posts
    723
    carim,

    i need it to change in the cell it is already in and in 3 columns maybe 50000 lines down

    steve

  8. #8
    Forum Expert Carim's Avatar
    Join Date
    04-07-2006
    Posts
    4,070
    Ok then ...
    Please Login or Register  to view this content.

  9. #9
    Forum Contributor
    Join Date
    08-10-2006
    Posts
    723
    thanks to both of you works great

    MDubbelboer it was the blanks

    steve

  10. #10
    Forum Expert Carim's Avatar
    Join Date
    04-07-2006
    Posts
    4,070
    Glad your problem is now fixed.

    Thanks for the feedback

    Carim

+ 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