Consulting

Results 1 to 6 of 6

Thread: show numbers with commas

  1. #1

    show numbers with commas

    I have this code that inputs times each digit I type. Can some assist in editing the code to allow me to enter numbers with commas.

    i.e
    1000 = 1,000
    10000 = 10,000
    100000 = 100,000

    [vba]Select Case Len(Me.txtReport)
    Case 1
    Me.txtReport = Format(Me.txtReport, "00\:00")
    Case Is > 1
    v = Replace(Me.txtReport, ":", "")
    Me.txtReport = Format(Val(v), "00\:00")
    Case Else
    End Select
    [/vba]

    Thank you for your help

  2. #2
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    How about
    [VBA]

    Me.txtReport = Format(CLng(Me.txtReport), "00\:00")
    [/VBA]
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  3. #3
    I'm not quite sure I understanding your post. Could you elaborate? The code I have allows me to type in time, one digit at a time. What I'm trying to do is type in a number.

    i.e. Each number represents me typing each character...

    1
    10
    100
    1,000
    10,000
    100,000

  4. #4
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    As I understand it, you want to enter either 1000 or 1,000 to obtain a result.
    Attached Files Attached Files
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  5. #5
    ok...in your example, it still displays time. The code I presented is fine for time display, but i want to be able to type in only number formats (No time format)

  6. #6
    VBAX Mentor
    Joined
    Dec 2008
    Posts
    404
    Location
    With native separators (thousands and decimal) like this:
    Me.txtReport = Format((Me.txtReport), "#,##0.00")
    Artik

Posting Permissions

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