Advertisement
Guest User

Untitled

a guest
Mar 5th, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.28 KB | None | 0 0
  1. Option Explicit '1�s�ڂɋL�q - �ϐ���錾���ȂƁA�x�����܂��B
  2.  
  3. '���L�́y���y�[�W�ƈ���͈͂̐ݒ�()�z�̃R�[�h�ł́A
  4. 'Debug.Print�����Ă���ӏ����A7�ӏ�����܂��B����̉ӏ��ł��B
  5. '�C�~�f�B�G�C�g�E�B���h�E�Ŋm�F���Ă��������B
  6. '���̏ꍇ�A�[�i���V�[�g��C9,C26,C43������A�󔒂ɂ��Ă���A�R�[�h����s���Ă��������B
  7.  
  8. '�Ⴆ�΁A18�s�ڂɉ��y�[�W�i�����j��ݒ肷��ƁA17�s�ڂ�18�s�ڂ̋����y�[�W�̋��ڂɂȂ�܂��B
  9. 'Excel2013�̏ꍇ�A�\��Tab�̃u�b�N�̕\���̍��ڂ́u���y�[�W�v���r���[�v����N���b�N�����
  10. '�ǂ̂悤�ɉ��y�[�W���ݒ肳��Ă���̂���ڂŌ��Ċm�F���邱�Ƃ��ł��܂��B
  11.  
  12. '�]�k�ł����A����́AJ����E���Ɉ�����镨���Ȃ��̂ŁA���y�[�W�́A��������������ݒ肵�Ă��܂��B
  13. 'J����E���Ɉ�����镨������ꍇ�i������ŕ����̃y�[�W������ꍇ�j�́A
  14. '���������̉��y�[�W�̐ݒ��K�v�ɂȂ�܂��B
  15. '���y�[�W�i�����j�́AHPageBreaks.Add�ł����A���y�[�W�i�����j�́AVPageBreaks.Add�ł��B
  16.  
  17. Sub ���y�[�W�ƈ���͈͂̐ݒ�()
  18.  
  19. '----- �ϐ���錾���� ------------------------------------------------
  20. Dim sh As Worksheet, i As Long, k As Long, c As Range, cnt As Long
  21.  
  22. '----- ����͈͂���������āA���ׂẲ��y�[�W�������� --------------
  23. Set sh = ThisWorkbook.Sheets("�[�i��") '���V�[�g��
  24. sh.Activate '�V�[�g��A�N�e�B�u�ɂ���
  25. sh.PageSetup.PrintArea = "" '����͈͂������
  26. sh.ResetAllPageBreaks '���ׂẲ��y�[�W����
  27.  
  28. '----- ���y�[�W�i�����j��ݒ肷�� -----------------------------------
  29. Debug.Print "����������������������������������������������������"
  30. For i = 1 To 30 '�[�i��No.1�`30���舵���̂�i=1�`30
  31. k = (i - 1) * 17 + 9 'i=1,2,3,�c30�̂Ƃ��Ak=9,26,43,�c,502
  32. Set c = sh.Range("C" & k)
  33. Debug.Print "��" & c.Address(False, False)
  34. If Len(Trim(c)) = 1 Then 'Trim�����i�O��̃X�y�[�X�폜�j������̕��������[���Ȃ�A
  35. Exit For 'For���[�v�𔲂���
  36. Else '�[���łȂ��Ȃ�
  37. cnt = cnt + 1 '�J�E���g���適cnt�ɁA�u+1�v����
  38. If cnt Mod 2 = 0 Then '�J�E���g��������Ȃ�
  39. sh.HPageBreaks.Add before:=sh.Range("A" & 17 * cnt + 1) '���y�[�W(����)��ݒ肷��
  40. Debug.Print "��" & 17 * cnt + 1 & "�s�ڂɉ��y�[�W�i�����j��ݒ肵�܂���"
  41. End If
  42. End If
  43. Next i
  44.  
  45. If cnt = 0 Then
  46. Debug.Print "��" & "���y�[�W�i�����j�͐ݒ肵�܂���ł���"
  47. ElseIf cnt Mod 2 <> 0 Then '�Ō�́u�[�i��No�v����Ȃ�
  48. sh.HPageBreaks.Add before:=sh.Range("A" & 17 * cnt + 1) '���y�[�W(����)
  49. Debug.Print "��" & 17 * cnt + 1 & "�s�ڂɉ��y�[�W�i�����j��ݒ肵�܂���"
  50. End If
  51.  
  52. '----- ����͈͂�w�肷�� ---------------------------------------------
  53. If cnt = 0 Then
  54. sh.PageSetup.PrintArea = "$A$1:$I$9" '����͈͎w��
  55. Debug.Print "��" & "����͈͂�uA1:I9�v�ɐݒ肵�܂���"
  56. Else
  57. sh.PageSetup.PrintArea = "$A$1:$I$" & 17 * cnt '����͈͎w��
  58. Debug.Print "��" & "����͈͂�uA1:I" & 17 * cnt & "�v�ɐݒ肵�܂���"
  59. End If
  60.  
  61. '----- ����v���r���[����s���� ----------------------------------------
  62. sh.PrintPreview
  63.  
  64. '----- �㏈�� ----------------------------------------------------------
  65. Set sh = Nothing: Set c = Nothing
  66. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement