VBA makes all tables in an Excel workbook a one-click Layout

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.