- ©«¤l
- 9
- ¥DÃD
- 4
- ºëµØ
- 0
- ¿n¤À
- 13
- ÂI¦W
- 0
- §@·~¨t²Î
- window7
- ³nÅ骩¥»
- office 2010
- ¾\ŪÅv
- 10
- ©Ê§O
- ¤k
- ¨Ó¦Û
- HsinChu
- µù¥U®É¶¡
- 2013-10-14
- ³Ì«áµn¿ý
- 2014-6-26
|
¦^´_ 2# GBKEE
¤@ª½¥d¦b ActiveSheet.Name = Windows(WorkName).ActiveSheet.Range("b" & i)
¥t¥~, Y§Ú§ï¦¨TXT FILE, ¥i¥H§ï¦¨.... ¥i¤@ª½·|¥d¦b ¶}±ÒtxtÀɮ׳¡¥÷, ÁÙ¦³TXT FILE ·|¹³ªþ¥ó¦³ " | " "---" n¦p¦ó¤@¨Ö³B²z.
Option Explicit
Private Sub cmdMerge_Click()
Dim objsheet As Worksheet, desc As Workbook, WorkName As Workbook, Filename As String
Dim Sh As Worksheet, Used As Worksheet, Rng As Range, r As Range, i As Integer, n As Integer, j As Integer
Set WorkName = ThisWorkbook 'µ{¦¡©Ò¦bÀɮצWºÙ 'WorkName = Excel.ActiveWorkbook.Name '§@¥Î¤¤ÀɮצWºÙ
Set desc = Excel.Workbooks.Add '¶}·sªºworkbook
i = 1
While WorkName.ActiveSheet.Range("b" & i) <> ""
Filename = WorkName.ActiveSheet.Range("b" & i) & ".txt"
'¶}±ÒtxtÀÉ®×
Workbooks.OpenText Filename:=Excel.Windows(WorkName).Path & "\" & Filename, Origin:=950, StartRow:=8, DataType:=xlFixedWidth, FieldInfo:=Array( _
Array(0, 1), Array(1, 1), Array(7, 1), Array(12, 1), Array(34, 1), Array(42, 1), Array(43, 1 _
), Array(51, 1), Array(53, 1), Array(61, 1), Array(63, 1), Array(71, 1), Array(73, 1), Array _
(81, 1), Array(83, 1), Array(91, 1), Array(93, 1), Array(101, 1), Array(103, 1), Array(111, _
1), Array(113, 1), Array(121, 1), Array(123, 1), Array(137, 1), Array(140, 1)), _
TrailingMinusNumbers:=True
'Workbooks.Open WorkName.Path & "\" & Filename
Workbooks(Filename).ActiveSheet.Copy desc.Sheets(1)
ActiveSheet.Rows(1).Delete
ActiveSheet.Name = Windows(WorkName).ActiveSheet.Range("b" & i)
Windows(Filename).Close
i = i + 1 'Ū¨ú¤U¤@ÓÀɮצWºÙ
Wend
Set Used = desc.Sheets("sheet1") '*** ¶}·sªºworkbook*** Sheets("¦X¨Ö¦¨ªº¤u§@ªí")
'Application.DisplayAlerts = False '°±¤î §R°£Sheet®É ¹w³]ªºÄµ§i
For Each Sh In Sheets
If Sh.Name <> Used.Name Then
Set Rng = Used.UsedRange(Used.UsedRange.Rows.Count, 1)(1, 1)
'sh.UsedRange.Offset(1).Copy.Rng '½Æ»s¨Ó·½¦³¼ÐÀY
Sh.UsedRange.Copy Rng '½Æ»s¨Ó·½¨S¦³¼ÐÀY
' SH.Delete '§R°£¤w¸g½Æ»s¦nªºsheet
End If
Next
Used.UsedRange.Sort key1:=Used.Range("P2"), order1:=xlAscending, Header:=xlNo
n = Used.UsedRange.Rows.Count
'MsgBox n
For j = 2 To n
If Used.Range("c" & j) <> "" And Used.Range("p" & j) = "" Then
Used.Rows(j).Clear
End If
Next
j = j + 1 ' n±N©Ò¦³ªº¸ê®Æ½T»{¹L
MsgBox "¤w±N©Ò¦³Àɮ׶פJ¬¡¶¤¤", , "Anny note"
End Sub |
-
-
test1.zip
(742 Bytes)
|