Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Option Explicit '1�s�ڂɋL�q - �ϐ���錾���ȂƁA�x�����܂��B
- '���L�́y���y�[�W�ƈ���͈͂̐ݒ�()�z�̃R�[�h�ł́A
- 'Debug.Print�����Ă���ӏ����A7�ӏ�����܂��B����̉ӏ��ł��B
- '�C�~�f�B�G�C�g�E�B���h�E�Ŋm�F���Ă��������B
- '���̏ꍇ�A�[�i���V�[�g��C9,C26,C43������A�ɂ��Ă���A�R�[�h����s���Ă��������B
- '�Ⴆ�A18�s�ڂɉ��y�[�W�i�����j��ݒ肷��ƁA17�s�ڂ�18�s�ڂ̋����y�[�W�̋��ڂɂȂ�܂��B
- 'Excel2013�̏ꍇ�A�\��Tab�̃u�b�N�̕\���̍��ڂ́u���y�[�W�v���r���[�v����N���b�N�����
- '�ǂ̂悤�ɉ��y�[�W���ݒ肳��Ă���̂���ڂŌ��Ċm�F���邱�Ƃ��ł��܂��B
- '�]�k�ł����A����́AJ����E���Ɉ�����镨���Ȃ��̂ŁA���y�[�W�́A��������������ݒ肵�Ă��܂��B
- 'J����E���Ɉ�����镨������ꍇ�i������ŕ����̃y�[�W������ꍇ�j�́A
- '���������̉��y�[�W�̐ݒ��K�v�ɂȂ�܂��B
- '���y�[�W�i�����j�́AHPageBreaks.Add�ł����A���y�[�W�i�����j�́AVPageBreaks.Add�ł��B
- Sub ���y�[�W�ƈ���͈͂̐ݒ�()
- '----- �ϐ���錾���� ------------------------------------------------
- Dim sh As Worksheet, i As Long, k As Long, c As Range, cnt As Long
- '----- ����͈͂���������āA���ׂẲ��y�[�W�������� --------------
- Set sh = ThisWorkbook.Sheets("�[�i��") '���V�[�g��
- sh.Activate '�V�[�g��A�N�e�B�u�ɂ���
- sh.PageSetup.PrintArea = "" '����͈͂������
- sh.ResetAllPageBreaks '���ׂẲ��y�[�W����
- '----- ���y�[�W�i�����j��ݒ肷�� -----------------------------------
- Debug.Print "����������������������������������������������������"
- For i = 1 To 30 '�[�i��No.1�`30���舵���̂�i=1�`30
- k = (i - 1) * 17 + 9 'i=1,2,3,�c30�̂Ƃ��Ak=9,26,43,�c,502
- Set c = sh.Range("C" & k)
- Debug.Print "��" & c.Address(False, False)
- If Len(Trim(c)) = 1 Then 'Trim�����i�O��̃X�y�[�X�폜�j������̕��������[���Ȃ�A
- Exit For 'For���[�v����
- Else '�[���łȂ��Ȃ�
- cnt = cnt + 1 '�J�E���g���適cnt�ɁA�u+1�v����
- If cnt Mod 2 = 0 Then '�J�E���g��������Ȃ�
- sh.HPageBreaks.Add before:=sh.Range("A" & 17 * cnt + 1) '���y�[�W(����)��ݒ肷��
- Debug.Print "��" & 17 * cnt + 1 & "�s�ڂɉ��y�[�W�i�����j��ݒ肵�܂���"
- End If
- End If
- Next i
- If cnt = 0 Then
- Debug.Print "��" & "���y�[�W�i�����j�͐ݒ肵�܂���ł���"
- ElseIf cnt Mod 2 <> 0 Then '�Ō�́u�[�i��No�v����Ȃ�
- sh.HPageBreaks.Add before:=sh.Range("A" & 17 * cnt + 1) '���y�[�W(����)
- Debug.Print "��" & 17 * cnt + 1 & "�s�ڂɉ��y�[�W�i�����j��ݒ肵�܂���"
- End If
- '----- ����͈͂�w�肷�� ---------------------------------------------
- If cnt = 0 Then
- sh.PageSetup.PrintArea = "$A$1:$I$9" '����͈͎w��
- Debug.Print "��" & "����͈͂�uA1:I9�v�ɐݒ肵�܂���"
- Else
- sh.PageSetup.PrintArea = "$A$1:$I$" & 17 * cnt '����͈͎w��
- Debug.Print "��" & "����͈͂�uA1:I" & 17 * cnt & "�v�ɐݒ肵�܂���"
- End If
- '----- ����v���r���[����s���� ----------------------------------------
- sh.PrintPreview
- '----- �㏈�� ----------------------------------------------------------
- Set sh = Nothing: Set c = Nothing
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement