• <noscript id="ecgc0"><kbd id="ecgc0"></kbd></noscript>
    <menu id="ecgc0"></menu>
  • <tt id="ecgc0"></tt>

    Excel VBA 頁面設置

    對于經常做Excel表格的小伙伴們,經常需要設置Excel的打印頁面和字體、頁眉頁腳等,那么若何利用VBA來完當作反復的操作呢?我們一路進修一下。

    東西/原料

    • 電腦
    • office excel

    方式/步調

    1. 1

      打開新建一個并打開EXCEL工作表

    2. 2

      利用Alt+F11組合快捷鍵進入vbe編纂器或者單擊【開辟東西】-VIsual Basic,并插入一個新的模塊。如圖所示。

    3. 3

      在模塊中編寫如下代碼:

      Sub 初始化設置()

          Cells.Select

          Selection.RowHeight = 16   

          Selection.ColumnWidth = 9

          

           With ActiveSheet.PageSetup

                   .RightFooter = ""

             .LeftMargin = Application.InchesToPoints(0.196850393700787)

              .RightMargin = Application.InchesToPoints(0.196850393700787)

              .TopMargin = Application.InchesToPoints(0.590551181102362)

              .BottomMargin = Application.InchesToPoints(0.393700787401575)

              .HeaderMargin = Application.InchesToPoints(0.196850393700787)

              .FooterMargin = Application.InchesToPoints(0.196850393700787)

              .Zoom = 100

             End With

      End Sub

      這部門代碼單元英寸。

    4. 4

      若是我們想直接設置厘米單元,我們這一將代碼改為如下:

      Sub 初始化設置()

          ActiveSheet.Cells.RowHeight = 16

          ActiveSheet.Cells.ColumnWidth = 9

        With ActiveSheet.PageSetup

          .LeftMargin = Application.CentimetersToPoints(0.5)

          .RightMargin = Application.CentimetersToPoints(0.5)

          .TopMargin = Application.CentimetersToPoints(1.5)

          .BottomMargin = Application.CentimetersToPoints(1) '底

          .HeaderMargin = Application.CentimetersToPoints(0.5) '頁眉

          .FooterMargin = Application.CentimetersToPoints(0.5) '頁腳

          .Zoom = 100

          End With

      End Sub

    5. 5

      其設置的結果為行高16,列寬9 ,頁面設置如下圖所示。

    • 發表于 2019-09-05 20:01
    • 閱讀 ( 831 )
    • 分類:其他類型

    你可能感興趣的文章

    相關問題

    0 條評論

    請先 登錄 后評論
    聯系我們:uytrv@hotmail.com 問答工具
  • <noscript id="ecgc0"><kbd id="ecgc0"></kbd></noscript>
    <menu id="ecgc0"></menu>
  • <tt id="ecgc0"></tt>
    久久久久精品国产麻豆