- ©«¤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 ©ó 2012-6-6 07:03 ½s¿è
¦^´_ 10# luke
7# ªº°ÝÃD ¬O2003 ¥H¤Wªºª©¥» ¨Ï¥ÎEnd ÄÝ©Ê,¦p¦³pºâ Rows.Count ©Î Columns.Count ¶·«ü©ú¥¦ªº¤÷¼hª«¥ó
Sh(1).Rows.Count ©Î Sh(1).Columns.Count
10# ªº°ÝÃD ×¥¿¥ÎFind ¨ú¥N Match §ä¨ì ¯u¥¿ªº¦r¦ê ¸Õ¸Õ¬Ý- Option Explicit
- Sub Ex()
- Dim Sh(1 To 2) As Worksheet, Ar, E As Variant, xlCsv As String, xlPath As String
- Dim xi As Integer, xR As Integer, xF As Range, xlRowsCount As Long
- xlRowsCount = ActiveSheet.Rows.Count
- xlPath = ThisWorkbook.Path & "\" '->קאּ¥¿½TªºÀɮ׸ô®|
- Set Sh(1) = Workbooks.Open(xlPath & "test21.csv").Sheets(1)
- Set Sh(2) = Sh(1).Parent.Sheets.Add '·s¼W¤u§@ªí§@¬° ¸ê®Æ¼È¦s
- Sh(1).Cells.Copy Sh(2).Cells(1) '½Æ»s test21.csv ªº¸ê®Æ '
- xlCsv = Dir(xlPath & "*.Csv") '´M§ä *.CsvÀÉ®×
- Do While xlCsv <> "" And LCase(xlCsv) <> "test21.csv"
- With Workbooks.Open(xlPath & xlCsv).Sheets(1)
- Sh(2).Cells(xlRowsCount, 1).End(xlUp).Offset(2) = "[*" & xlCsv & "*]"
- .[a1].CurrentRegion.Copy Sh(2).Cells(xlRowsCount, 1).End(xlUp).Offset(1) '½Æ»s *.Csvªº¸ê®Æ
- .Parent.Close 0
- End With
- xlCsv = Dir
- Loop
- Sh(1).Cells.Clear 'test21.csv.Sheets(1) ²M°£©Ò¦³¸ê®Æ: ¤w³Æ«·s¶×¤J±Æ§Ç«áªº*.Csv
- '*** ³B¸Ì ¤w¶×¤Jªº *.Csv*********
- With Sh(2)
- .Activate
- Ar = .Range("a:a").Value
- .Range("a:a").Replace "[*.*]", "=1/0" '[*.Csv] ´À¥N¬°¿ù»~È
- .Range("a:a").SpecialCells(xlCellTypeFormulas, xlErrors).Name = "ÀɦW" '±N¦³¿ù»~ȪºÀx¦s®æ ©w¸q¦WºÙ
- .Range("a:a").Value = Ar '½Æìì¨ÓªºÈ
- With .Columns(Columns.Count)
- [ÀɦW].Copy .Cells(1)
- .Sort Key1:=.Range("a1"), Order1:=xlAscending, Header:=xlNo '±Æ§Ç[ÀɦW]
- xR = 1
- Do While .Cells(xR) <> "" '¶×¤J "ÀɦW"¸ê®Æ
- Set xF = .Parent.Columns(1).Find(.Cells(xR).Text, LookAT:=xlWhole) '´M§ä "ÀɦW"
- xi = Sh(1).Cells(xlRowsCount, 1).End(xlUp).Row
- xi = IIf(xi = 1, 1, xi + 2) '²Ä¤GÓ[*.Csv]¥H«á ¶·¦A©¹¤U¦ì²¾¨ì2¦C
- xF.CurrentRegion.Copy Sh(1).Cells(xi, 1)
- xi = Sh(1).Cells(xlRowsCount, 1).End(xlUp).Row
- Sh(1).Cells(xi + 2, 1) = "[*div*]"
- xR = xR + 1
- Loop
- End With
- Application.DisplayAlerts = False
- .Delete '§R°£¸ê®Æ¼È¦s¤u§@ªí
- Application.DisplayAlerts = True
- End With
- '*****´ú¸Õ ¦¨¥\«á ¸Ñ°£µù¸Ñ ¥i¦sÀÉ
- 'Sh(1).Parent.Close True
- End Sub
½Æ»s¥N½X |
|