返回列表 上一主題 發帖

[發問] 請問,已知數千列資料每50列要列印成一頁,不知excel如何做。

這是 vba 的做法

Sub 自動分頁
    Dim rows_count As Long
    Dim page_count As Long                                               
    Dim i As Long                                                                 
    Dim str_row_index As String                                          
    Dim first_row As Long                                                        
   
    ActiveWindow.View = xlPageBreakPreview                        
    rows_count = Range("A1").CurrentRegion.Rows.Count     
    first_row = 50                                                                     
    For i = first_row To rows_count Step 50
        page_count = page_count + 1
        str_row_index = "A" + Trim(Str(i + 1))
        Set ActiveSheet.HPageBreaks(page_count).Location = Range(str_row_index)
    Next i
    ActiveWindow.View = xlNormalView
End Sub
V98

TOP

宇媽:下列是本論壇有本問題的一系列討論,應該可以得到答案

http://forum.twbts.com/thread-2275-1-1.html
V98

TOP

        靜思自在 : 【停滯不前,終無所得】人都迷於尋找奇蹟,因而停滯不前;縱使時間再多、路再長,也了無用處,終無所得。
返回列表 上一主題