- Private Sub cmdMerge_Click()
- Application.ScreenUpdating = False '«Ì½ª«Ì¹õ¨ê·s
- Dim a, b, c As Integer '«Å§ia,b,c¬°¾ã¼Æ
-
- Dim objsheet As Worksheet
-
- WorkName = Excel.ActiveWorkbook.Name '¦¹ÀɮצWºÙ
-
- desc = Excel.Workbooks.Add.Name '·sÀÉ®×µøµ¡½s¸¹
-
-
- Application.DisplayAlerts = False '±Nĵ§i°T®§Ãö³¬
-
-
-
- i = 6
- z = 1
-
- While Windows(WorkName).ActiveSheet.Range("b" & i) <> ""
-
-
- Filename = Windows(WorkName).ActiveSheet.Range("b" & i) & "." & Windows(WorkName).ActiveSheet.Range("b3")
-
- Workbooks.Open Filename:=Excel.Workbooks(WorkName).Path & "\" & Filename
-
-
- sheetname = Windows(WorkName).ActiveSheet.Range("b4")
-
- If sheetname <> "" Then
-
- 'Àˬd¬¡¶¬O§_¦s¦b
- flag = 0
- For j = 1 To Windows(Filename).Parent.Sheets.Count
- If Windows(Filename).Parent.Sheets(j).Name = sheetname Then
- flag = 1
- Exit For
- End If
- Next
-
- If flag = 1 Then
- Windows(Filename).Parent.Sheets(sheetname).Select '¤Á´«¬¡¶
- End If
-
- End If
- Set objsheet = Windows(Filename).ActiveSheet '¤Á´«µøµ¡
- 'Ū¨ú¨Ó·½ÀɮתºX(¦C¼Æ),Y(¦æ¼Æ)
- x = Windows(WorkName).ActiveSheet.Range("b1")
- y = Windows(WorkName).ActiveSheet.Range("b2")
-
-
- a = x '¶}©l¦C
- b = y '¶}©lÄæ
-
- Do While True
- kk = ""
- For l = 1 To 10
- For k = 1 To 30
- If IsError(objsheet.Cells(x + l, k)) = False Then
- kk = kk & objsheet.Cells(x + l, k)
- End If
- Next
- Next
- If kk = "" Then Exit Do
- x = x + 1
- Loop
-
- Do While True
- kk = ""
- For l = 1 To 10
- For k = 1 To 30
- If IsError(objsheet.Cells(k, y + l)) = False Then
- kk = kk & objsheet.Cells(k, y + l)
- End If
- Next
- Next l
- If kk = "" Then Exit Do
- y = y + 1
- Loop
-
- '¿ï¨ú¨Ó·½½d³ò
- objsheet.Range(objsheet.Cells(a, b), objsheet.Cells(x, y)).Select
-
- 'copy
- Selection.Copy
- '¿ï¨ú¥Øªº
- Windows(desc).Activate
-
-
- '¦pªG¶K¤W¥H«á·|¤j©ó1048576«h·s¼W¤@Ó¬¡¶
- If (z + x - a + 1) > 65535 Then
- z = 1
- Windows(desc).Parent.Sheets.Add
- Windows(desc).Parent.Sheets(1).Cells(z, 1).Select
- Else
- If UCase(Sheet1.Range("b5").Value) = "Y" Then
- Windows(desc).ActiveSheet.Cells(z, 1).Value = Windows(WorkName).ActiveSheet.Range("b" & i)
- Windows(desc).ActiveSheet.Cells(z, 2).Select
- Else
- Windows(desc).ActiveSheet.Cells(z, 1).Select
- End If
- End If
-
- ActiveSheet.Paste
-
- '¶K¤WÄæ¼e
- Selection.PasteSpecial Paste:=xlPasteColumnWidths, Operation:=xlNone, _
- SkipBlanks:=False, Transpose:=False
-
- z = z + x - a + 1
-
- '±N¨Ó·½ÀÉ®×Ãö³¬
- Windows(Filename).Close
-
- i = i + 1 'Ū¨ú¤U¤@ÓÀɮצWºÙ
- Wend
-
- Windows(desc).ActiveSheet.Cells(1, 1).Select
-
- 'ª©±³]©w¤W¤U¥ª¥k0.5
- With ActiveSheet.PageSetup
- .PrintTitleRows = ""
- .PrintTitleColumns = ""
- End With
- ActiveSheet.PageSetup.PrintArea = ""
- With ActiveSheet.PageSetup
- .LeftHeader = ""
- .CenterHeader = ""
- .RightHeader = ""
- .LeftFooter = ""
- .CenterFooter = ""
- .RightFooter = ""
- .LeftMargin = Application.InchesToPoints(0.196850393700787)
- .RightMargin = Application.InchesToPoints(0.196850393700787)
- .TopMargin = Application.InchesToPoints(0.196850393700787)
- .BottomMargin = Application.InchesToPoints(0.196850393700787)
- .HeaderMargin = Application.InchesToPoints(0.511811023622047)
- .FooterMargin = Application.InchesToPoints(0.511811023622047)
- .PrintHeadings = False
- .PrintGridlines = False
- .PrintComments = xlPrintNoComments
- .PrintQuality = 600
- .CenterHorizontally = False
- .CenterVertically = False
- .Orientation = xlPortrait
- .Draft = False
- .PaperSize = xlPaperA4
- .FirstPageNumber = xlAutomatic
- .Order = xlDownThenOver
- .BlackAndWhite = False
- .Zoom = 100
- .PrintErrors = xlPrintErrorsDisplayed
- End With
-
- 'A:F»¼¼W±Æ§Ç
- ActiveSheet.Columns("A:F").Select
- Selection.Sort Key1:=ActiveSheet.Range("C2"), Order1:=xlAscending, Header:=xlGuess, _
- OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, SortMethod _
- :=xlStroke, DataOption1:=xlSortNormal
-
- '¸ê®ÆåªR
- ActiveSheet.Columns("D:D").Select
- Selection.Insert Shift:=xlToRight
- ActiveSheet.Columns("C:C").Select
- Selection.TextToColumns Destination:=Range("C1"), DataType:=xlDelimited, _
- TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=True, Tab:=True, _
- Semicolon:=False, Comma:=False, Space:=True, Other:=False, FieldInfo _
- :=Array(Array(1, 1), Array(2, 1)), TrailingMinusNumbers:=True
-
- '¾ã²z
- ActiveSheet.Range("C1").Select
- ActiveCell.FormulaR1C1 = "µæ¦W"
- ActiveSheet.Range("D1").Select
- ActiveCell.FormulaR1C1 = "³æ»ù"
- ActiveSheet.Columns("D:D").ColumnWidth = 5.63
-
- Application.DisplayAlerts = True '±Nĵ§i°T®§¥´¶}
-
- Application.ScreenUpdating = True '¨ú®ø«Ì½ª«Ì¹õ¨ê·s
- End Sub
½Æ»s¥N½X |