Results 1 to 3 of 3

Thread: puting an apostrophe before a number

  1. #1

    puting an apostrophe before a number



    Register for a FREE account, and/
    or Log in to avoid these ads!

    hi

    how do you format numbers to have an apostrophe before all the numbers

    eg. 100 '100
    7 '7

    the are too many of the numbers and can not do it manually, looking for the formula

  2. #2
    Code:
    Public Sub ProcessData()
    Dim Lastrow As Long
    Dim i As Long
    
        Application.ScreenUpdating = False
        
        With ActiveSheet
        
            Lastrow = .Cells(.Rows.Count, "A").End(xlUp).Row
            For i = 1 To Lastrow
            
                If IsNumeric(.Cells(i, "A").Value) Then
                
                    .Cells(i, "A").Value = "'" & .Cells(i, "A").Value
                End If
            Next i
        End With
        
        Application.ScreenUpdating = True
    End Sub

  3. #3
    Administrator Ken Puls's Avatar
    Join Date
    Mar 2011
    Location
    Nanaimo, BC, Canada
    Posts
    2,189
    Articles
    57
    Blog Entries
    14
    Bob's route will actually put an apostrophe in the cell. If you want them to just look like they have an apostrophe, but still work like numbers, you can use a custom number format:

    • Select the range of cells
    • Right click and choose "Format Cells"
    • Go to the "Number" tab
    • Select "Custom"
    • Under "Type" enter the '0
    • Click OK
    This will display with the apostrophe, but you can still add and subtract them if you need to.

    HTH,
    Ken Puls, FCPA, FCMA, MS MVP (Excel)

    Master your data with Power Query: Purchase your copy of my book M is for Data Monkey today!

    Main Site: http://www.excelguru.ca -||- Blog: http://www.excelguru.ca/blog -||- Forums: http://www.excelguru.ca/forums
    Check out the Excelguru Facebook Fan Page -||- Follow Me on Twitter

    If you've been given VBA code (a macro) for your solution, but don't know where to put it, CLICK HERE.

Posting Permissions

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