How to change the default number format in Excel?

前端 未结 6 681
不思量自难忘°
不思量自难忘° 2021-01-18 19:31

I have this column of string integers in the \'general\' type all the time. Every time I open this spreadsheet, I have to convert it into \'number\' type. But when I do it,

6条回答
  •  猫巷女王i
    2021-01-18 19:51

    Try the following:

    Right click on a column and click on Format Cells... and then select Number from Category: list and for Decimal places: specify 0

    Save the file and re-open, and you should see that column be set to Number

    EDIT:

    If you want to apply formatting to multiple excel files, you can write a macro for that:

    Doing some quick research, came across the following VBA code --- I DO NOT take credit for this. I did however changed the DoWork method to add: .Worksheets(1).Range("A1").NumberFormat = "Number"

    Sub ProcessFiles()
        Dim Filename, Pathname As String
        Dim wb As Workbook
    
        Pathname = ActiveWorkbook.Path & "\Files\"
        Filename = Dir(Pathname & "*.xls")
        Do While Filename <> ""
            Set wb = Workbooks.Open(Pathname & Filename)
            DoWork wb
            wb.Close SaveChanges:=True
            Filename = Dir()
        Loop
    End Sub
    
    Sub DoWork(wb As Workbook)
        With wb
            'Do your work here
            .Worksheets(1).Range("A1").NumberFormat = "Number"
        End With
    End Sub
    

提交回复
热议问题