Notes
Notes - notes.io |
Dim sourceWorkbook As Workbook
Dim sourceSheet As Worksheet
Dim targetSheet As Worksheet
Dim lastRow As Long
Dim materialCount As Integer
Dim uitValues As Variant
Dim currentRow As Long
Dim targetRow As Long
Dim i As Long
Dim uitValue As String
Dim uitColumn As Long, materialColumn As Long
' 소스 파일 열기 (파일 경로 수정)
Set sourceWorkbook = Workbooks.Open("C:NERP생산MRP_Material_ListZMMTR2500_DFZ.xlsx")
Set sourceSheet = sourceWorkbook.Sheets("SAPUI5 Export") ' 소스 시트 이름
' 현재 워크북의 대상 시트 설정 (데이터를 복사할 시트)
Set targetSheet = ThisWorkbook.Sheets("Sheet1")
' 소스 파일의 마지막 행 찾기
lastRow = sourceSheet.Cells(sourceSheet.Rows.Count, "A").End(xlUp).Row
' 기존 데이터 삭제
targetSheet.Cells.Clear
' UIT 열과 Material 열 지정 (필요 시 수정)
uitColumn = 4 ' "UIT" 값이 있는 열 (예: A열)
materialColumn = 2 ' "Material" 값이 있는 열 (예: B열)
' "UIT" 값 설정 (필터링할 값)
uitValues = Array("D", "M", "G", "R", "T") '"Q",
' 대상 시트의 F열에서 시작할 행을 1로 설정 (첫 번째 행)
targetRow = 1
' "UIT" 값에 따라 데이터 검색 및 복사
For i = LBound(uitValues) To UBound(uitValues)
uitValue = uitValues(i)
materialCount = 0
' 소스 파일에서 각 UIT 값에 해당하는 Material 찾기
For currentRow = 2 To lastRow ' 첫 번째 행을 제외하고 2번째 행부터 시작
If sourceSheet.Cells(currentRow, uitColumn).Value = uitValue Then
materialCount = materialCount + 1
' 대상 시트의 F열에 Material 값 복사
targetSheet.Cells(targetRow, 6).Value = sourceSheet.Cells(currentRow, materialColumn).Value
' C열에 "I Others GR" 넣기
targetSheet.Cells(targetRow, 3).Value = "I Others GR"
' G열에 조건에 따른 값 입력 (UIT가 "Q"이면 3200, 아니면 1100)
If uitValue = "Q" Then
targetSheet.Cells(targetRow, 7).Value = 3200
Else
targetSheet.Cells(targetRow, 7).Value = 1100
End If
' A열에 "Plant"입력
targetSheet.Cells(targetRow, 1).Value = "DFZ"
' D열에 "ClassCode"입력
targetSheet.Cells(targetRow, 4).Value = "A-STOCK"
' I열에 "COM" 입력
targetSheet.Cells(targetRow, 9).Value = "COM"
' N열에 "5" 입력
targetSheet.Cells(targetRow, 14).Value = 5
' Comment (O열)에 "Automation_Test" 입력
targetSheet.Cells(targetRow, 17).Value = "Automation_Test"
' 다음 행으로 이동
targetRow = targetRow + 1
' 각 UIT에 대해 최대 5개씩만 가져오기
If materialCount = 5 Then Exit For
End If
Next currentRow
Next i
' 소스 파일 닫기
sourceWorkbook.Close False
'MsgBox "데이터 복사가 완료되었습니다."
End Sub
![]() |
Notes is a web-based application for online taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000+ notes created and continuing...
With notes.io;
- * You can take a note from anywhere and any device with internet connection.
- * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
- * You can quickly share your contents without website, blog and e-mail.
- * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
- * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.
Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.
Easy: Notes.io doesn’t require installation. Just write and share note!
Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )
Free: Notes.io works for 14 years and has been free since the day it was started.
You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;
Email: [email protected]
Twitter: http://twitter.com/notesio
Instagram: http://instagram.com/notes.io
Facebook: http://facebook.com/notesio
Regards;
Notes.io Team
