The Excel workbook you manage has been modified by many people, many of which are often inconsistent, providing VBA code to implement one-click layout of tabular data format, eliminating the manual frequent adjustment of Excel data format.
1 Option Explicit2 OptionBase13 4 SubAutoSet ()5 DimI as Integer6 7 fori =1 toSheets.count8 Sheets (i). Activate ' This line of code can not save, before the table operation, you need to activate the operation of the table first9 Sheets (i). Cells.selectTen withSelection.Font One. Name ="Microsoft Ya-Black"' Set Font type A. Size =11 ' Set Font size -. Strikethrough =False -. Superscript =False the. Subscript =False -. Outlinefont =False -. Shadow =False -. Underline =Xlunderlinestylenone +. TintAndShade =0 -. ThemeFont =Xlthemefontnone + End with A withSelection at. HorizontalAlignment =Xlleft ' Set the text arrangement, on the left -. VerticalAlignment =xlcenter ' Set text arrangement, vertical center -. Orientation =0 -. AddIndent =False -. IndentLevel =0 -. ShrinkToFit =False in. ReadingOrder =Xlcontext -. MergeCells =False to End with +Sheets (i). Range ("A1"). Select - Next the End Sub
You need to set other aspects of the format, directly within the for loop to add the appropriate code to implement, you can record a macro to see the code of the settings, and then add
VBA makes all tables in an Excel workbook a one-click Layout