Page 2 of 2 FirstFirst 12
Results 11 to 13 of 13

Thread: Dynamic Decimal Placement

  1. #11
    Board Regular Akuini's Avatar
    Join Date
    Feb 2016
    Location
    Indonesia
    Posts
    2,035
    Post Thanks / Like
    Mentioned
    33 Post(s)
    Tagged
    4 Thread(s)

    Default Re: Dynamic Decimal Placement

    Try this:
    Code:
    Sub tryB()
    x = tbOPrice
            V = Replace(x, "$", "")
            x = Replace(V, ".", "")
            z = WorksheetFunction.Rept(0, textbox1)
            tbOPrice = Format(x, "$#,#0." & z)
    
    End Sub
    I have to ask:
    You have this line: Replace(V, ".", "")
    It means that you want to remove "." from the tbOPrice (before you convert the format), so if you type 1.2 then it will be 12, is it correct?

  2. #12
    Board Regular
    Join Date
    Oct 2007
    Posts
    737
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Dynamic Decimal Placement

    After deciphering what the code was doing, I figure it out how to merge your code with the original code. I reserched what Rept function does and this is what I put together. The red highlighted part needed it to be in parenthesis.

    Thank you immensely for your help. Greatly appreciated it!

    Code:
    Private Sub tbOPrice_Change()Dim v As String
    
    
    Z = WorksheetFunction.Rept(0, tbEFSet)
    
    
    Select Case Len(tbOPrice)
        Case 1
            tbOPrice = Format(tbOPrice, "$0\." & Z)
        Case Is > 1
            v = Replace(tbOPrice, "$", "")
            v = Replace(v, ".", "")
            tbOPrice = Format(v / (1 & Z), "$#,#0." & Z)
        Case Else
    End Select
    End Sub
    The trick with sneaky users is not teaching them anything lest they get wise!

  3. #13
    Board Regular Akuini's Avatar
    Join Date
    Feb 2016
    Location
    Indonesia
    Posts
    2,035
    Post Thanks / Like
    Mentioned
    33 Post(s)
    Tagged
    4 Thread(s)

    Default Re: Dynamic Decimal Placement

    You're welcome, glad to help, & thanks for the feedback.

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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