ªð¦^¦Cªí ¤W¤@¥DÃD µo©«

[µo°Ý] Ãö©ó¤£©T©wÄæ ¦Û°Ê¦C¦L¦Ü³Ì«á¤@µ§¸ê®Æ

¦^´_ 1# starry1314


    µ¹§A°Ñ¦Ò¡A§Úªº°µªk
  1. Option Explicit

  2. Sub ¥¨¶°1()
  3.     Dim c As Range
  4.     With Sheets("¤u§@ªí1")
  5.         Set c = .Rows(3).Find("P.P", , , , , 1)
  6.         .PageSetup.PrintArea = "$A$2:" & .Cells(Rows.Count, c.Column).End(xlUp).Address '³]©w¦C¦L½d³ò
  7.         .PrintOut Copies:=1, Collate:=True, IgnorePrintAreas:=False '¦C¦L
  8.         Set c = Nothing
  9.         Set c = .Rows(3).Find("P.P", , , , , 2)
  10.         .PageSetup.PrintArea = "$T$2:" & .Cells(Rows.Count, c.Column).End(xlUp).Address
  11.         .PrintOut Copies:=1, Collate:=True, IgnorePrintAreas:=False '¦C¦L
  12.         Set c = Nothing
  13.     End With
  14. End Sub
½Æ»s¥N½X

TOP

¦^´_ 1# starry1314


    ¤]¥i¥H³o¼Ë¡I
  1. Option Explicit

  2. Sub ¥¨¶°1()
  3.     Dim c As Range
  4.     With Sheets("¤u§@ªí1")
  5.         Set c = .Rows(3).Find("P.P", , , , , 1) '©¹«á´M§ä
  6.         .PageSetup.PrintArea = .Range(.Cells(Rows.Count, 1).End(xlUp), Cells(2, c.Column)).Address '³]©w¦C¦L½d³ò
  7.         .PrintOut Copies:=1, Collate:=True, IgnorePrintAreas:=False '¦C¦L
  8.         Set c = Nothing
  9.         Set c = .Rows(3).Find("P.P", , , , , 2) '©¹«e´M§ä
  10.         .PageSetup.PrintArea = .Range(.Cells(Rows.Count, 1).End(xlUp), Cells(2, c.Column)).Address '³]©w¦C¦L½d³ò
  11.         .PrintOut Copies:=1, Collate:=True, IgnorePrintAreas:=False '¦C¦L
  12.         Set c = Nothing
  13.     End With
  14. End Sub
½Æ»s¥N½X

TOP

¥»©«³Ì«á¥Ñ lpk187 ©ó 2016-4-26 20:42 ½s¿è

¦^´_ 8# starry1314

¦b¦¹¥ý·PÁ­㴣³¡ªL¤j¤j±Ð±Âªº"Print_Area"»yªk

    §Q¥ÎRange.Find»¡©ú½d¨Ò­×§ï¤@¤U¡A¥i¥H¹F¨ì§Aªº­n¨D¡A´N¬O¦A§Q¥ÎFindNext
  1. Sub ¥¨¶°1()
  2.     Dim c As Range, firstAddress$, myColumn%
  3.     With Sheets("¤u§@ªí1")
  4.         Set c = .Rows(3).Find("P.P", LookIn:=xlValues)
  5.             If Not c Is Nothing Then
  6.                 firstAddress = c.Address
  7.                 myColumn = 1
  8.                 Do
  9.                      .Range(.Cells(2, myColumn), .Cells(Rows.Count, c.Column).End(xlUp)).Name = "Print_Area"
  10.                      .PrintOut Copies:=1, Collate:=True, IgnorePrintAreas:=False
  11.                     Set c = .Rows(3).FindNext(c)
  12.                     myColumn = myColumn + 19
  13.                 Loop While Not c Is Nothing And c.Address <> firstAddress
  14.             End If
  15.     End With
  16. End Sub
½Æ»s¥N½X

TOP

¦^´_ 11# starry1314


    Option Explicit

Sub ¥¨¶°1()
    Dim c As Range, firstAddress$, myColumn%
    With Sheets("¤u§@ªí1")
        Set c = .Rows(3).Find("P.P", LookIn:=xlValues) '´M¨D²Ä¤@­Ó¥Ø¼Ðª«¥ó
            If Not c Is Nothing Then '¦pªGcª«¥ó¤£¬O¬°Nothing®É¡A°õ¦æ
                firstAddress = c.Address '°O¿ý§ä¨ìªº²Ä¤@­Ó¦ì¸m
                myColumn = 1 '³]©wAÄæ
                Do
                     '.Range(.Cells(2, myColumn), .Cells(Rows.Count, c.Column).End(xlUp)).Name = "Print_Area" '
                     .Range(.Cells(Rows.Count, myColumn).End(xlUp), Cells(2, c.Column)).Name = "Print_Area" '³]©w¦C¦L½d³ò¡A¥H³]©w½d³ò¨Ó»¡¡A¨Ò¦p¡G"A1:C5"©M"A5:C1"¬O¤@¼Ëªº·N«ä
                     '¥u¤£¹LAÄæ¥i¥H§ä¨ì³Ì«á¤@¦C¡A©Ò¥H­n¥Î«áªÌ¨Ó³]©w½d³ò
                     .PrintOut Copies:=1, Collate:=True, IgnorePrintAreas:=False '¦C¦L
                    Set c = .Rows(3).FindNext(c) '´M§ä¤U¤@­Ó¥Ø¼Ðª«
                    myColumn = myColumn + 19 '¤U¤@­Ó­Ó¦ì¸m¬°TÄæ...¦A¨Ó¬OAMÄæ¡A¨Ì¦¹Ãþ±À
                Loop While Not c Is Nothing And c.Address <> firstAddress '·ícªº¦ì§}©M²Ä¤@­Ó¦ì§}¬Û¦P®É¡A¸õ¥X°j°é
            End If
    End With
End Sub

TOP

        ÀR«ä¦Û¦b : ·R¤£¬O­n¨D¹ï¤è¡A¦Ó¬O­n¥Ñ¦Û¨­ªº¥I¥X¡C
ªð¦^¦Cªí ¤W¤@¥DÃD