+ Reply to Thread
Results 1 to 3 of 3

So close, Converting Parenthesis to Negative

  1. #1
    Registered User
    Join Date
    01-03-2020
    Location
    U.S.A.
    MS-Off Ver
    365
    Posts
    11

    So close, Converting Parenthesis to Negative

    Hi all,
    I'm pulling data from the web using a Macro to be used in calculations later. However, the data came in an abbreviated format such as 1.2B for one point two Billion or (3.3M) for negative three point three Million. I came up with a vba input (with help from the forum) for getting rid of the abbreviated letter and multiplying the result by it's corresponding abbreviated amount in full. The code is:

    Sub ConvertTextToNumber()

    Sheets("Income Statement").Select
    LastRow = ActiveSheet.Cells.Find("*", searchorder:=xlByRows, searchdirection:=xlPrevious).Row
    i = 1
    Do
    tempval = Range("B" & i).Value
    If Right(tempval, 1) = "M" Then Range("B" & i).Value = CDec(Left(tempval, Len(tempval) - 1)) * 1000000
    If Right(tempval, 1) = "B" Then Range("B" & i).Value = CDec(Left(tempval, Len(tempval) - 1)) * 1000000000
    i = i + 1
    Loop While i <= LastRow

    'etc. etc. until all columns are converted and on all sheets.

    It works great, however, the cells with parenthesis are left unchanged. How and in what format would I insert code to get rid of the parenthesis and replace it with a simple hyphen?

  2. #2
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967

    Re: So close, Converting Parenthesis to Negative

    Try

    Please Login or Register  to view this content.
    Martin

  3. #3
    Registered User
    Join Date
    01-04-2020
    Location
    Hull, UK
    MS-Off Ver
    2016
    Posts
    60

    Re: So close, Converting Parenthesis to Negative

    Assuming all your worksheets start on Column B this should work...

    Please Login or Register  to view this content.
    ...and then call it like this
    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Parenthesis format for negative numbers
    By aschwalge in forum Excel General
    Replies: 8
    Last Post: 07-11-2015, 07:06 PM
  2. Replies: 3
    Last Post: 01-27-2015, 04:52 PM
  3. Difference between Parenthesis and Negative Values
    By whylucky in forum Excel General
    Replies: 2
    Last Post: 11-12-2014, 05:22 PM
  4. Replies: 4
    Last Post: 01-15-2013, 11:55 PM
  5. Replies: 2
    Last Post: 08-23-2008, 01:57 PM
  6. [SOLVED] How to place parenthesis around a negative percentage calculation.
    By Kay in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 02-03-2006, 03:55 PM
  7. How do I format a negative number in parenthesis?
    By John Nollett in forum Excel General
    Replies: 10
    Last Post: 01-07-2006, 11:40 AM

Tags for this Thread

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