|
|
|
|
|
|
'======================================================================
' 아래 YouTube 주소로 자세히 설명해 놓았습니다.
' https://youtu.be/8w4vlpIg7FU
' 제 Youtube 채널에서 Excel및 VBA를 공부하세요.
' https://www.youtube.com/channel/UChR2YTnlpU9OVfLyH_09YeA
'======================================================================
소스 코드
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
Dim rngX As Range: Set rngX = Application.Intersect(Target, Range("F4"))
If rngX Is Nothing Then Exit Sub
Application.EnableEvents = False
Dim shtY As Worksheet: Set shtY = ActiveSheet
Dim shtX As Worksheet: Set shtX = Worksheets("거래 내역")
Set rngX = shtX.Range("A1").CurrentRegion
Dim r As Long
Dim i As Long: i = 0
For r = 2 To rngX.Rows.Count
If rngX.Rows(r).Cells(1).Value = Target.Value And _
rngX.Rows(r).Cells(8).Value = "X" Then
'품명/수량/단가/금액
i = i + 1
'기존 자료 지우기
If i = 1 Then
shtY.Range("A8:H26").ClearContents
End If
With shtY.Range("A26").End(xlUp).Offset(1)
.Value = rngX.Rows(r).Cells(4).Value
.Offset(0, 3).Value = rngX.Rows(r).Cells(5).Value
.Offset(0, 4).Value = rngX.Rows(r).Cells(6).Value
.Offset(0, 5).Value = rngX.Rows(r).Cells(7).Value
End With
End If
Next r
Application.EnableEvents = True
End Sub
|
|
[불량 게시물 신고] |
|
|
|
작성일 : 2019-03-30(17:56)
최종수정일 : 2019-03-30(17:56) |
|
|
|
|