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

[µo°Ý] ½Ð±ÐªíÀY¸òªí§À¦C¦L

Sub zz()
Application.ScreenUpdating = 0
Application.DisplayAlerts = 0
Dim usedH, hd As Range, fn As Range, pd As Range
Set hd = Range(±zªº­¶ÀY)
Set fn = Range(±zªº­¶§À)
Set pd = ActiveSheet.UsedRange
'usedH ±N©Ò»Ý¦C¦L°ª«×²Ö¥[
For Each r In hd.Rows
  usedH = usedH + r.RowHeight
Next
For Each r In fn.Rows
  usedH = usedH + r.RowHeight
Next
'avh ¤@­¶¯à¦C¦L°ª«×
avh = 710 - Int(usedH) '¦¹³B§Ú¤£À´¦Û°Ê­pºâ, ½Ð¦Ñ®v«ü¾É
'bodyS ¤º®e¶}©l¦æ, bodyE  ¤º®eµ²§À¦æ
bodyS = hd.Rows.Count + 1
bodyE = pd.Rows.Count - fn.Rows.Count
zc = pd.Columns.Count
Sheets.Copy
Range(Cells(bodyS, 1), Cells([a65536].End(3).Row, 1)).EntireRow.Delete
'pr1 ¦C¦L¤º®e²Ä¤@¦æ
pr1 = bodyS
For i = bodyS To bodyE
    n = n + pd.Rows(i).RowHeight
    If n >= avh Then
        Range(pd.Cells(pr1, 1), pd.Cells(i, zc)).Copy Range("a" & [a65536].End(3).Row + 1)
        fn.Copy Range("a" & [a65536].End(3).Row + 1)
        pr1 = i + 1
        n = 0
        ActiveSheet.PrintOut Copies:=1
        Range(Cells(bodyS, 1), Cells([a65536].End(3).Row, 1)).EntireRow.Delete
    End If
Next
ActiveWorkbook.Close 0
Application.ScreenUpdating = 1
Application.DisplayAlerts = 1
End Sub

TOP

§Ñ¤F»¡©ú³o¬O§Úªº·Qªk¬O.
±zªº°ÝÃD¥i¯à°N¦³VBA¤~¥i¸Ñ¨M
1. ¥ý­pºâ¦C¦L­¶ªº°ª¤W­­(§Y¦b¤@­¶¤º©Ò¯à¦C¦Lªº©Ò¦³¦æ°ªÁ`©M),³o¸Ì§Ú¤£À´¦Û°Ê­pºâ, ½Ð¦Ñ®v«ü¾É
2. ¨D¥X­¶ÀYÁ`¦æ°ªªº©M
3. ¨D¥X­¶¸}Á`¦æ°ªªº©M
4. «×¥X¦C¦L¸ê®Æªº°ª
5. ¶i¦æ¨C­¶¦C¦L­«²Õ

VBA µ{§Ç¤j­P¬°¦b 4# ©Ò¼g

TOP

­è¤~¸Õ¤F¤@¤U¦³¤í,²{­×¥¿¦p¤U:

Sub zz()
Application.ScreenUpdating = 0
Application.DisplayAlerts = 0
Dim usedH, hd As Range, fn As Range, pd As Range
Set hd = Range(±zªº­¶ÀY)
Set fn = Range(±zªº­¶§À)
Set pd = ActiveSheet.UsedRange
'usedH ±N©Ò»Ý¦C¦L°ª«×²Ö¥[
For Each r In hd.Rows
  usedH = usedH + r.RowHeight
Next
For Each r In fn.Rows
  usedH = usedH + r.RowHeight
Next
'avh ¤@­¶¯à¦C¦L°ª«×
avh = 710 - Int(usedH) '¦¹³B§Ú¤£À´¦Û°Ê­pºâ, ½Ð¦Ñ®v«ü¾É
'bodyS ¤º®e¶}©l¦æ, bodyE  ¤º®eµ²§À¦æ
bodyS = hd.Rows.Count + 1
bodyE = pd.Rows.Count - fn.Rows.Count
zc = pd.Columns.Count
Sheets.Copy
Range(Cells(bodyS, 1), Cells([a65536].End(3).Row, 1)).EntireRow.Delete
'pr1 ¦C¦L¤º®e²Ä¤@¦æ
pr1 = bodyS
For i = bodyS To bodyE
    n = n + pd.Rows(i).RowHeight
    If n >= avh Then
        Range(pd.Cells(pr1, 1), pd.Cells(i, zc)).Copy Range("a" & [a65536].End(3).Row + 1)
        fn.Copy Range("a" & [a65536].End(3).Row + 1)
        pr1 = i + 1
        n = 0
        ActiveSheet.PrintOut Copies:=1
        Range(Cells(bodyS, 1), Cells([a65536].End(3).Row, 1)).EntireRow.Delete
    End If
Next
If n Then
    Range(pd.Cells(pr1, 1), pd.Cells(i, zc)).Copy Range("a" & [a65536].End(3).Row + 1)
    fn.Copy Range("a" & [a65536].End(3).Row + 1)
    ActiveSheet.PrintOut Copies:=1
    Range(Cells(bodyS, 1), Cells([a65536].End(3).Row, 1)).EntireRow.Delete
End If
ActiveWorkbook.Close 0
Application.ScreenUpdating = 1
Application.DisplayAlerts = 1
End Sub

TOP

°²³]±zªº­¶ÀY¬O¥Ñ A1:K7
­×§ï Set hd = Range(±zªº­¶ÀY) ¬° Set hd = Range("A1:K7")
¦p¦¹Ãþ±À ­×§ï Set fn = Range(±zªº­¶§À)
¤@¯ëA4 ¤@­¶¯à®e¦æ°ª 710, ¦p ¶W¥X¤@­¶, ½Ð­×§ï avh = 710  ¬° avh = 700 ©Î§ó¤Ö

TOP

«Ü©êºp,¥Ñ©ó§ÚªºÅv­­¥¼¯à¤U¸ü, ½Ð¦b¼Ò²Õ¤¤«öF8¹E¨B°õ¦æ¦Ü°ÝÃD³B,§â°ÝÃDÅã¥Ü¦A¬d¤U¡C

TOP

        ÀR«ä¦Û¦b : °ß¨ä´L­«¦Û¤vªº¤H¡A¤~§ó«i©óÁY¤p¦Û¤v¡C
ªð¦^¦Cªí ¤W¤@¥DÃD