- ©«¤l
- 5923
- ¥DÃD
- 13
- ºëµØ
- 1
- ¿n¤À
- 5986
- ÂI¦W
- 0
- §@·~¨t²Î
- win10
- ³nÅ骩¥»
- Office 2010
- ¾\ŪÅv
- 150
- ©Ê§O
- ¨k
- ¨Ó¦Û
- ¥xÆW°ò¶©
- µù¥U®É¶¡
- 2010-5-1
- ³Ì«áµn¿ý
- 2022-1-23
|
¥»©«³Ì«á¥Ñ GBKEE ©ó 2017-7-30 07:53 ½s¿è
¦^´_ 18# PJChen
¦³°÷²M·¡ªº,´£°Ý´N¬On³o¼Ë
¸Õ¸Õ¬Ý- Option Explicit
- Dim ¥ØªºÀÉ As Workbook, ¨Ó·½ÀÉ As Workbook
- Sub Copy_All()
- Dim RngAr(), Rng As Range, M As Variant, xM As Long, E As Integer, Msg As String
- With ThisWorkbook.Sheets("VBA«ü¥O")
- RngAr = .Range("G2", .Range("G2").End(xlDown)).Resize(, 3).Value '·Ç«h½d³ò¸m©ó°}¦CÅܼƤ¤
- End With
- File_settings ¥ØªºÀÉ, "ERP_Data.XLSX"
- '**** ¤ñ¹ï·Ç«h ªº°j°é **************
- For E = 1 To UBound(RngAr)
- File_settings ¨Ó·½ÀÉ, RngAr(E, 1) & ""
- M = Application.Match(RngAr(E, 2), ¨Ó·½ÀÉ.Sheets(1).Range("b:b"), 0)
- If IsNumeric(M) Then
- With ¨Ó·½ÀÉ.Sheets(1)
- xM = .Range("b" & M).End(xlDown).Row
- Set Rng = .Range("b" & M, .Range("b" & xM)).Resize(, Range(RngAr(E, 3)).Columns.Count)
- Rng.copy
- End With
- With ¥ØªºÀÉ.Sheets(Mid(RngAr(E, 1), 1, 2))
- M = Application.Match(RngAr(E, 2), .Range("c:c"), 0)
- If IsNumeric(M) Then
- '***¶K¤W«á½d³ò,·|¦Û°Êªº¤Ï¥Õ,¤£¶·¦³µ{¦¡½X°µ¤Ï¥Õ***
- .Range("c" & M).PasteSpecial xlPasteValues
- xM = .Range("c" & M).End(xlDown).Row '¶K¤W«á³o¤u§@ªíªº³Ì«á¤@¦C¸¹
- M = M + Rng.Rows.Count - 1 '·Ç«h¦C¸¹+½Æ»s½d³òªº¦C¼Æ - 1
- If xM > M Then .Range("a" & M + 1, .Range("a" & xM)).EntireRow.Delete
- Else
- '***¶K¤W«á½d³ò,·|¦Û°Êªº¤Ï¥Õ,¤£¶·¦³µ{¦¡½X°µ¤Ï¥Õ***
- .Range("c1").End(xlDown).Offset(1).PasteSpecial xlPasteValues
- End If
- End With
- Application.CutCopyMode = False
- Msg = Msg & vbLf & Mid(RngAr(E, 1), 1, 2) & vbTab & RngAr(E, 2) & vbTab & "§ó·s§¹¦¨!"
- Else
- Msg = Msg & vbLf & Mid(RngAr(E, 1), 1, 2) & vbTab & RngAr(E, 2) & vbTab & "¤£¥Î§ó·s!"
- End If
- ¨Ó·½ÀÉ.Close False
- Next
- ¥ØªºÀÉ.Save '**¥ØªºÀɦsÀÉ
- MsgBox IIf(Msg = "", "¨S¦³¥ô¦ó «ü©wq³æ §ó·s", Mid(Msg, 2))
- End Sub
- '**********¨Ó·½ÀɬO¦PVBA³øªí«ü¥Oªº¸ê®Æ§¨\FromERP\*********
- Sub File_settings(xFile As Workbook, ¤u§@¶ As String) 'Àɮ׳]©w
- Dim xPath As String
- xPath = ThisWorkbook.Path & "\"
- If UCase(¤u§@¶) <> UCase("ERP_Data.XLSX") Then xPath = xPath & "FromERP\"
- On Error Resume Next
- Set xFile = Workbooks(¤u§@¶)
- If Err > 0 Then Set xFile = Workbooks.Open(xPath & ¤u§@¶)
- If xFile.Name = "" Then
- MsgBox "½Ð¬d¬Ý " & vbLf & xPath & vbLf & "¬O§_¦³ [" & ¤u§@¶ & "]"
- End
- End If
- End Sub
½Æ»s¥N½X |
|