+ Reply to Thread
Results 1 to 10 of 10

Revenue Correction

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    07-17-2012
    Location
    bangalore
    MS-Off Ver
    Excel 2007
    Posts
    461

    Revenue Correction

    Hi All,

    I have the revenue in Column B. As I had mentioned in Column C is required.

    1. If column B has only number. It is be as it its.
    2. If column B has revenue with K example: 10989K This K should be removed and it has to be multiplied by 1000.
    3. If column B has revenue with K example: 3125.31M This M should be removed and it has to be multiplied by 1000000
    3. If column B has revenue with K example: 6545.79B This B should be removed and it has to be multiplied by 1000000000

    Please find the attachment
    Attached Files Attached Files

  2. #2
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,831

    Re: Revenue Correction

    You can use this formula in C2:

    =IF(B2="","",IF(ISNUMBER(SEARCH("K",B2)),SUBSTITUTE(B2,"K","")*1000,IF(ISNUMBER(SEARCH("M",B2)),SUBSTITUTE(B2,"M","")*1000000,IF(ISNUMBER(SEARCH("B",B2)),SUBSTITUTE(B2,"B","")*1000000000,B2*1))))

    then copy down as required.

    Hope this helps.

    Pete

  3. #3
    Forum Contributor
    Join Date
    07-17-2012
    Location
    bangalore
    MS-Off Ver
    Excel 2007
    Posts
    461

    Re: Revenue Correction

    If the cell contains 32k. It is not converting.

  4. #4
    Valued Forum Contributor
    Join Date
    06-27-2010
    Location
    sYRIA
    MS-Off Ver
    Excel 2013
    Posts
    669

    Re: Revenue Correction

    Hi
    How about

    Option Explicit
    Sub test()
        Dim a As Variant
        Dim i As Integer
        Dim mtch, x, xx, y As Variant
        a = Application.Transpose(Cells(2, 1).Offset(, 1).Resize(Cells(Rows.Count, 1).End(xlUp).Row))
        With CreateObject("VBScript.Regexp")
            .Global = True
            .Pattern = "([+-]?(?=\.\d|\d)(?:\d+)?(?:\.?\d*)(?:[eE][+-]?\d+)?)|(\w)"
            For i = 1 To UBound(a)
                Set mtch = .Execute(a(i))
                xx = mtch.Count
                If xx < 2 Then GoTo 0
                x = mtch(1).submatches(1)
                y = mtch(0).submatches(0)
                Select Case x
                Case "K"
                    a(i) = y * 1000
                Case "M"
                    a(i) = y * 1000000
                Case "B"
                    a(i) = y * 1000000000
                End Select
    0       Next
        End With
        Cells(1, 1).Offset(1, 1).Resize(UBound(a)) = Application.Transpose(a)
    End Sub

  5. #5
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,831

    Re: Revenue Correction

    SEARCH is not case-sensitive, but SUBSTITUTE is, and if you have a lower-case k it will not be replaced. You can change the formula to this:

    =IF(B2="","",IF(ISNUMBER(SEARCH("K",B2)),SUBSTITUTE(UPPER(B2),"K","")*1000,IF(ISNUMBER(SEARCH("M",B2)),SUBSTITUTE(B2,"M","")*1000000,IF(ISNUMBER(SEARCH("B",B2)),SUBSTITUTE(B2,"B","")*1000000000,B2*1))))

    if you might have a mixture of K and k, and the same for the M and B terms, but if you will only ever have k then you can change K to k in the SUBSTITUTE term.

    Hope this helps.

    Pete

  6. #6
    Forum Guru
    Join Date
    04-23-2012
    Location
    New Jersey, USA
    MS-Off Ver
    Excel 365
    Posts
    2,420

    Re: Revenue Correction

    Here is another macro solution that you can try (assumed that data starts in cell B1 and output goes to Column C) ...
    Sub RevenueCorrection()
      Dim X As Long, Data As Variant
      Data = Range("B1", Cells(Rows.Count, "B").End(xlUp))
      For X = 1 To UBound(Data)
        If Data(X, 1) Like "*[Kk]" Then
          Data(X, 1) = 1000 * Left(Data(X, 1), Len(Data(X, 1)) - 1)
        ElseIf Data(X, 1) Like "*[Mm]" Then
          Data(X, 1) = 1000000 * Left(Data(X, 1), Len(Data(X, 1)) - 1)
        ElseIf Data(X, 1) Like "*[Bb]" Then
          Data(X, 1) = 1000000000 * Left(Data(X, 1), Len(Data(X, 1)) - 1)
        End If
      Next
      Range("C1").Resize(UBound(Data)) = Data
    End Sub

  7. #7
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Cool Hi ! Try this !


    Another way amending directly the column B and working whatever upper or lower case letter :

    PHP Code: 
    Sub Demo1()
            
    Dim VR&, W
        With 
    [A1].CurrentRegion.Columns(2)
                
    = .Value2
            
    For 2 To UBound(V)
                
    Application.Match(Right(V(R1), 1), [{"K","M","B"}], 0)
                If 
    IsNumeric(WThen V(R1) = Val(V(R1)) * 1000 W
            Next
                
    .Value2 V
        End With
    End Sub 
    Do you like it ? So thanks to click on bottom left star icon « Add Reputation » !

  8. #8
    Forum Guru
    Join Date
    04-23-2012
    Location
    New Jersey, USA
    MS-Off Ver
    Excel 365
    Posts
    2,420

    Re: Revenue Correction

    IGNORE... Did not work as I thought it would.
    Last edited by Rick Rothstein; 09-25-2019 at 10:32 PM.

  9. #9
    Forum Guru
    Join Date
    04-23-2012
    Location
    New Jersey, USA
    MS-Off Ver
    Excel 365
    Posts
    2,420

    Re: Revenue Correction

    Instead of all that code I posted in Message #6, how about this more compact macro (it does not use a loop)...
    Sub RevenueCorrection()
      With Range("B1", Cells(Rows.Count, "B").End(xlUp))
        .Offset(, 1).Value = Evaluate(Replace("IF(@="""","""",LEFT(@,LEN(@)-1)*LOOKUP(RIGHT(@),{"""",""B"",""K"",""M""},{1,1000000000,1000,1000000}))", "@", .Address))
      End With
    End Sub
    Note: This code puts its output in Column C... if you want to overwrite the original data in Column B. simply remove the .Offset(,1) that I highlighted in blue.
    Last edited by Rick Rothstein; 09-25-2019 at 10:58 PM.

  10. #10
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Lightbulb EZ formula …


    An EZ formula in cell C2 : =IFERROR(LEFT(B2,LEN(B2)-1)*1000^MATCH(RIGHT(B2,1),{"K","M","B"},0),B2)
    Copy down, voilà !

    If you really need to directly amend the column B via a VBA procedure so according to this formula :

    PHP Code: 
    Sub Demo2()
            Const 
    "IFERROR(LEFT(#,LEN(#)-1)*1000^MATCH(RIGHT(#,1),{""K"",""M"",""B""},0),#)"
        
    With [A1].CurrentRegion.Columns(2)
            .
    Value2 Evaluate(Replace(F"#", .Address))
        
    End With
    End Sub 
    ► Do you like it ? ► ► So thanks to click on bottom left star icon « Add Reputation » !

+ 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. [SOLVED] Deferred Revenue, Revenue Recognition --- integrating one time fee!
    By andrew.cloudsnap in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 05-28-2019, 05:05 PM
  2. Looking for formula correction
    By wonderd in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 04-14-2019, 02:23 PM
  3. Replies: 7
    Last Post: 11-18-2015, 02:33 AM
  4. Revenue Calculation based on Variable revenue Percentage
    By suhabthan in forum Excel General
    Replies: 0
    Last Post: 06-19-2014, 12:48 PM
  5. Revenue recognition and deffered revenue
    By saurabhwise in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 10-08-2013, 11:12 AM
  6. [SOLVED] Difference between total revenue - last days revenue
    By vinodt in forum Excel Charting & Pivots
    Replies: 3
    Last Post: 10-08-2012, 02:35 PM
  7. correction
    By nowfal in forum Excel General
    Replies: 4
    Last Post: 03-24-2006, 02:40 PM

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