나눔터  
  HOME > 나눔터 > 묻고답하기 > 엑셀
엑셀
엑셀에 대한 질문과 답변을 올려주세요. 단, 취지에 맞지 않는 글은 운영자가 삭제합니다.
 "000 님, 도와주세요", "부탁 드립니다.", "급합니다!" 등과 같이 막연한 제목을 달지 말아주세요.
[필독] 빠르고 정확한 답변을 얻는 16가지 Tip !
[필독] 저작권법 개정에 따른 이용안내
작성자:  

 엑세리 (lovinksj)

추천:  2
파일:     문의사항_개별프린트물 - 1.xlsm (40.1KB) 조회:  1685
제목:   입력된 내용에 맞게 개별 프린트물 출력 방법
     
  * 답변하시는 분들께 도움이 되도록 자신의 환경을 아래 항목 옆에 기재해 주세요.

 - 엑셀 버전(2016):

* 아래줄에 질문을 작성하세요 >>

1. "입력"시트에 값을 입력하면, "출력"시트의 해당 셀에 내용이 기입되고, No.의 번호로 순차적으로 프린트 되었으면합니다.

2. 이때, "출력"시트의 양식이, "입력"시트에 기입된 양식만 선택적으로 프린트가 되어야하는데 이부분이 막혀서 도움을 요청드립니다.
   "출력"시트상에 "I열"에 "B열"과 "E9셀"의 내용이 동일하면 숫자 1을 "C열"에 반영하고, 아닌경우 "C열"에 비워두는 수식을 넣어서, 최종적으로 프린트시 "C열"에 숫자 1이 들어있는 경우에만 남기고, 나머지 행은 숨김처리해서 프린트하고자합니다.

* 출력_프린트

Option Explicit

Public Const PD_데이터_타이틀R As Long = 1
Public Const PD_데이터_헤더R As Long = 2
Public Const PD_데이터_시작R As Long = 3

Public Const PD_데이터_시작C As Long = 1
Public Const PD_데이터_데이터시작C As Long = 2

Sub 출력_프린트()


Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Application.EnableEvents = False

    Dim OrgSheet As Worksheet
    Dim tmpSheet As Worksheet
    Dim NowSheet As Worksheet
    
    Dim tmpEndR As Long
    Dim tmpEndC As Long
    
    Dim NowSRow As Long
    Dim NowRowCount As Long
    
    Dim tmpRange As Range
    Dim SaveRange As Range
    
    Dim i As Long
    Dim j As Long
    
    
    Set tmpSheet = Sheets("입력")
    Set OrgSheet = Sheets("출력")
    
    Set tmpRange = tmpSheet.Cells(PD_데이터_헤더R, PD_데이터_시작C).CurrentRegion
    tmpEndR = tmpRange.Cells(tmpRange.Rows.Count, 1).Row
    tmpEndC = tmpRange.Cells(1, tmpRange.Columns.Count).Column
    
    For i = PD_데이터_시작R To tmpEndR
        If Len(tmpSheet.Cells(i, PD_데이터_시작C)) > 0 Then
            For j = PD_데이터_시작C + 1 To tmpEndC
                If Len(tmpSheet.Cells(PD_데이터_타이틀R, j)) > 0 Then
                    OrgSheet.Range(tmpSheet.Cells(PD_데이터_타이틀R, j)) = tmpSheet.Cells(i, j)
                End If
            Next
            Call 출력시트_수식_I열을_값으로_C열에_붙여넣기
                  
            
            OrgSheet.PrintPreview
        End If
    Next


Application.Calculation = xlAutomatic
Application.EnableEvents = True
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True

    
End Sub


* 수식붙여넣고, 빈행 숨기기

Sub 출력시트_수식_I열을_값으로_C열에_붙여넣기()




Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Application.EnableEvents = False


Dim rngC As Range
Dim rngP As Range

Set rngC = Worksheets("출력").Range("I4:I23")
Set rngP = Worksheets("출력").Range("C4:C23")

rngC.Copy
rngP.PasteSpecial xlPasteValues
Application.CutCopyMode = False


Set rngC = Nothing
Set rngP = Nothing


Application.EnableEvents = True
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True


Call C열_빈행숨기기

End Sub




Sub C열_빈행숨기기()
    Dim i As Long                    '// 변동되는 변수
    Dim endRow As Long        '// 마지막 행 변수

    endRow = Cells(Rows.Count, "B").End(3).Row    '// 값이 들어있는 마지막행을 자동인식
    For i = endRow To 2 Step -1        '// 마지막 행부터 거꾸로
        If (Cells(i, "C") = "") Or Cells(i, "C") = 0 Then
            Rows(i).EntireRow.Hidden = True     '// 빈행 숨기기
        End If
    Next i
End Sub


 
[불량 게시물 신고]  
        
  

작성일 : 2020-06-11(10:58)
최종수정일 : 2020-06-11(10:58)
 


 ◎ 관련글

  제 목   작성자   날짜
입력된 내용에 맞게 개별 프린트물 출력 방법 엑세리 2020-06-11
[RE]입력된?내용에?맞게?개별?프린트물?출력?방법 slgi 2020-06-11