اذهب الي المحتوي
أوفيسنا
بحث مخصص من جوجل فى أوفيسنا
Custom Search

الردود الموصى بها

  • تمت الإجابة
قام بنشر (معدل)

وعليكم السلام ورحمة الله تعالى وبركاته

لست متأكدا من طلبك لاكن حاول تجربة هدا 

Option Explicit
Private Const n As Long = 25
Private Const rHeight As Double = 20
Private Const tmps As Integer = 4
Private Const Col As String = "B"

Sub PrintWS()
    Dim lr As Long, i As Long
    Dim lastCol As Long, OnRng As Range
    Dim CrWS As Worksheet
    Dim ColNum As Long
    Set CrWS = Sheets("Data")
    
    Application.ScreenUpdating = False
    CrWS.ResetAllPageBreaks
    Application.ActiveWindow.View = xlPageBreakPreview
    
    ColNum = CrWS.Range(Col & "1").Column
    lr = CrWS.Range(Col & CrWS.Rows.count).End(xlUp).Row
    CrWS.Rows("5:" & lr).RowHeight = rHeight
    
    If lr > tmps + n Then
        For i = tmps + n + 1 To lr Step n
            CrWS.HPageBreaks.Add Before:=CrWS.Rows(i)
        Next i
    End If
    
    lastCol = CrWS.Cells(tmps, CrWS.Columns.count).End(xlToLeft).Column
    Set OnRng = CrWS.Range(CrWS.Cells(tmps, ColNum), CrWS.Cells(lr, lastCol))
    
    CrWS.PageSetup.PrintArea = OnRng.Address
    CrWS.VPageBreaks.Add Before:=CrWS.Columns(lastCol + 1)
    CrWS.VPageBreaks(1).DragOff Direction:=xlToRight, RegionIndex:=1
    
    With CrWS.PageSetup
        .Orientation = xlPortrait: .PaperSize = xlPaperA4
        .FitToPagesWide = 1: .FitToPagesTall = False
    End With
    
    Application.ScreenUpdating = True
End Sub

 

Test V1.xlsb

تم تعديل بواسطه محمد هشام.
  • Thanks 2

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

زائر
اضف رد علي هذا الموضوع....

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • تصفح هذا الموضوع مؤخراً   0 اعضاء متواجدين الان

    • لايوجد اعضاء مسجلون يتصفحون هذه الصفحه
×
×
  • اضف...

Important Information