ªð¦^¦Cªí ¤W¤@¥DÃD µo©«

[µo°Ý] ¦p¦ó©îÀÉ©Mµ²¦X·s´¡¤Jªº«ü©w¤å¦rÀÉ

¦^´_ 14# luke


    H¤j¦n

   #9 ²Ä54¦CAr(0) = "[*div*]"¤£¤p¤ß¥´¦¨ Ar(0) = "[**]"
     
  ÁÂÁ¦^ÂÐ

TOP

¦^´_ 11# GBKEE

     #11·s­×§ïµ{¦¡´ú¸Õ«á,
     ±Æ§Ç±¡§ÎÅܱo«Ü¿ù¶Ã
     
     ¦]ÀɦWªø©MÀɮ׫ܦh
     §Úªº·Qªk¬O±NÀɮפÀ§O¦sÀÉ«á
     ¦A¨Ì·Ó±Æ¦C¶¶§Ç
     µ²¦X¤@°_
     ¦pH¶Wª©©ó#9µ{¦¡
     (¦ý¦¹µ{¦¡±ÄChr(9)¤è¦¡µ²¦X, µLªk¶¶§Q³q¹L½sĶ)
     
     ¥H¤W·Qªk
     
    ·Ð½Ð«ü¾É

TOP

¦^´_ 12# luke

§Ú´ú¸ÕOKªü
play.gif
¾Ç®üµL²P_¤£®¢¤U°Ý

TOP

¦^´_ 9# Hsieh

     ÁÂÁÂH¤j

    ´¡¤JBB-1.csv©MDD1.csv¨â­ÓÀÉ©Ò·s«Ø¥ßªºTEST21OK.csv,
    ¨äÀɧÀ³BÅã¥Ü[**]¦pªþ¥ó
    TEST21OK.rar (369 Bytes)

TOP

¥»©«³Ì«á¥Ñ 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¦ê ¸Õ¸Õ¬Ý
  1. Option Explicit
  2. Sub Ex()
  3.     Dim Sh(1 To 2) As Worksheet, Ar, E As Variant, xlCsv As String, xlPath As String
  4.      Dim xi As Integer, xR As Integer, xF As Range, xlRowsCount As Long
  5.     xlRowsCount = ActiveSheet.Rows.Count
  6.     xlPath = ThisWorkbook.Path & "\"                                                '->­×§ï¬°¥¿½TªºÀɮ׸ô®|
  7.     Set Sh(1) = Workbooks.Open(xlPath & "test21.csv").Sheets(1)
  8.     Set Sh(2) = Sh(1).Parent.Sheets.Add                                             '·s¼W¤u§@ªí§@¬° ¸ê®Æ¼È¦s
  9.     Sh(1).Cells.Copy Sh(2).Cells(1)                                                 '½Æ»s test21.csv ªº¸ê®Æ                          '
  10.     xlCsv = Dir(xlPath & "*.Csv")                                                   '´M§ä *.CsvÀÉ®×
  11.     Do While xlCsv <> "" And LCase(xlCsv) <> "test21.csv"
  12.      With Workbooks.Open(xlPath & xlCsv).Sheets(1)
  13.            Sh(2).Cells(xlRowsCount, 1).End(xlUp).Offset(2) = "[*" & xlCsv & "*]"
  14.            .[a1].CurrentRegion.Copy Sh(2).Cells(xlRowsCount, 1).End(xlUp).Offset(1)  '½Æ»s *.Csvªº¸ê®Æ
  15.            .Parent.Close 0
  16.      End With
  17.      xlCsv = Dir
  18.     Loop
  19.     Sh(1).Cells.Clear     'test21.csv.Sheets(1) ²M°£©Ò¦³¸ê®Æ: ¤w³Æ­«·s¶×¤J±Æ§Ç«áªº*.Csv
  20.     '*** ³B¸Ì ¤w¶×¤Jªº *.Csv*********
  21.     With Sh(2)
  22.         .Activate
  23.         Ar = .Range("a:a").Value
  24.         .Range("a:a").Replace "[*.*]", "=1/0"                                       '[*.Csv] ´À¥N¬°¿ù»~­È
  25.         .Range("a:a").SpecialCells(xlCellTypeFormulas, xlErrors).Name = "ÀɦW"      '±N¦³¿ù»~­ÈªºÀx¦s®æ ©w¸q¦WºÙ
  26.         .Range("a:a").Value = Ar                                                    '½Æ­ì­ì¨Óªº­È
  27.         With .Columns(Columns.Count)
  28.             [ÀɦW].Copy .Cells(1)
  29.             .Sort Key1:=.Range("a1"), Order1:=xlAscending, Header:=xlNo             '±Æ§Ç[ÀɦW]
  30.             xR = 1
  31.             Do While .Cells(xR) <> ""                                               '¶×¤J "ÀɦW"¸ê®Æ
  32.                Set xF = .Parent.Columns(1).Find(.Cells(xR).Text, LookAT:=xlWhole)   '´M§ä "ÀɦW"
  33.                 xi = Sh(1).Cells(xlRowsCount, 1).End(xlUp).Row
  34.                 xi = IIf(xi = 1, 1, xi + 2)                                         '²Ä¤G­Ó[*.Csv]¥H«á ¶·¦A©¹¤U¦ì²¾¨ì2¦C
  35.                 xF.CurrentRegion.Copy Sh(1).Cells(xi, 1)
  36.                 xi = Sh(1).Cells(xlRowsCount, 1).End(xlUp).Row
  37.                 Sh(1).Cells(xi + 2, 1) = "[*div*]"
  38.                 xR = xR + 1
  39.             Loop
  40.         End With
  41.         Application.DisplayAlerts = False
  42.         .Delete                                                                      '§R°£¸ê®Æ¼È¦s¤u§@ªí
  43.         Application.DisplayAlerts = True
  44.     End With
  45.     '*****´ú¸Õ ¦¨¥\«á ¸Ñ°£µù¸Ñ ¥i¦sÀÉ
  46.     'Sh(1).Parent.Close True
  47. End Sub
½Æ»s¥N½X

TOP

¦^´_ 8# GBKEE


    ´ú¸Õ#6§ó·sµ{¦¡«á, ¥Ø«eµo²{¦³2­Ó°ÝÃD
     1.·s´¡¤Jªº¥DÀɦW­Y¤j©ó­ì©lÀÉTEST21®É,
         ¦pTEST22.csv(22>21)©ÎTF.csv(TF>TE),
         ÁöµL¿ù»~µo¥Í, ¹ê»ÚµLÀɮײ£¥Í.

     2.¥DÀɦW±a¦³"Monitor"¨Ò¦pMonitorTempContSet.csv©MMonitorTimInv.csv¨â­ÓÀÉ®×
         °õ¦æ±Æ§Ç®É·|»PTempContSet.csv©MTimInv.csv½Ä¬ð
         ¨ä±¡§Î¬OMonitorTempContSet.csv©MMonitorTimInv.csv­Ó¦@¥X²{¨â¦¸
         ¨Ãª½±µÂл\«áªÌ§YTempContSet.csv©MTimInv.csv·|±q­ì©lÀÉ®ø¥¢¤£¨£
         (¦ýÀɦWMonitorAbb.csv©MMonitorAbc.csv«o¤£·|»PAbb.csv©MAbc.csv½Ä¬ð)
         ¬ã§P¬O±Æ§Ç[ÀɦW]¿ù¶Ã³y¦¨

¡@¡@¥H¤W¿ù»~
   ¡@ ·Ð½Ð«ü¾É
    ¡@ÁÂÁÂ!

TOP

¦^´_ 7# luke
  1. Sub Split_CSV()
  2. Dim Ar(), Ay()
  3. Set d = CreateObject("Scripting.Dictionary")
  4. Application.DisplayAlerts = False
  5. Application.ScreenUpdating = False
  6. fd = ThisWorkbook.Path & "\"
  7. fs = fd & "TEST21.csv"
  8. Set wb = Workbooks.Open(fs)
  9. yn = False
  10.   With wb.Sheets(1) '¤À³ÎÀÉ®×
  11.   k = .UsedRange.Columns.Count
  12.      For Each a In .Range(.[A1], .Cells(.Rows.Count, 1).End(xlUp))
  13.         If yn = False And InStr(a, ".csv") > 0 Then _
  14.         yn = True: r = 1: _
  15.          f = Replace(Replace(Replace(a, "[", ""), "]", ""), "*", ""): _
  16.          Set sh = wb.Sheets.Add(after:=wb.Sheets(1))
  17.          Ar = a.Resize(, k).Value
  18.          With sh
  19.          If yn = True Then
  20.          .Cells(r, 1).Resize(, k) = Ar: r = r + 1
  21.          ReDim Preserve Ay(s)
  22.          Ay(s) = Join(Application.Transpose(Application.Transpose(Ar)), Chr(9))
  23.          s = s + 1
  24.          End If
  25.          End With
  26.         If InStr(a, "div") > 0 Then fs = fd & "µ²ªG\" & f: yn = False: sh.Move: ActiveWorkbook.SaveAs fd & "µ²ªG\" & f, 6: Workbooks(f).Close:        d(f) = Join(Ay, Chr(10)): Erase Ay: s = 0
  27.      Next
  28.     End With
  29. wb.Close 0
  30.     fs = Dir(fd & "*.csv")
  31.     Do Until fs = ""
  32.     If fs <> "TEST21.csv" Then
  33.     Set wb = Workbooks.Open(fd & fs)
  34.     With wb.Sheets(1)
  35.     k = .UsedRange.Columns.Count
  36.     ReDim Ar(k)
  37.     Ar(0) = "[*" & fs & "*]"
  38.       For i = 1 To k - 1
  39.         Ar(i) = ""
  40.       Next
  41.     ReDim Preserve Ay(s)
  42.     Ay(s) = Join(Ar, Chr(9))
  43.     s = s + 1
  44.     For Each a In .UsedRange.Columns(1).Cells
  45.        Ar = a.Resize(, k).Value
  46.     ReDim Preserve Ay(s)
  47.     Ay(s) = Join(Application.Transpose(Application.Transpose(Ar)), Chr(9))
  48.     s = s + 1
  49.     Next
  50.     ReDim Preserve Ay(s)
  51.     Ay(s) = Join(Array("", "", "", "", "", "", "", ""), Chr(9))
  52.     s = s + 1
  53.     ReDim Ar(k)
  54.     Ar(0) = "[*div*]"
  55.       For i = 1 To k - 1
  56.         Ar(i) = ""
  57.       Next
  58.     ReDim Preserve Ay(s)
  59.     Ay(s) = Join(Ar, Chr(9))
  60.     s = s + 1
  61.     d(fs) = Join(Ay, Chr(10))
  62.     Erase Ay: s = 0
  63.     End With
  64.     wb.Close 0
  65.     End If
  66.     fs = Dir
  67.     Loop
  68. With Worksheets.Add
  69. .[A1].Resize(d.Count, 1) = Application.Transpose(d.keys)
  70. .[A1].Resize(d.Count, 1).Sort key1:=.[A1], Header:=xlNo
  71. Ar = .[A1].Resize(d.Count, 1).Value
  72. r = 1
  73. For Each ky In Ar '²Õ¦XÀÉ®×
  74.    an = Split(d(ky), Chr(10))
  75.    For j = 0 To UBound(an)
  76.      ak = Split(an(j), Chr(9))
  77.      .Cells(r, 1).Resize(, UBound(ak) + 1) = ak
  78.      r = r + 1
  79.    Next
  80.    r = r + 1
  81. Next
  82. .Move
  83. ActiveWorkbook.SaveAs fd & "µ²ªG\" & "TEST21OK.csv", 6
  84. ActiveWorkbook.Close 1
  85. End With
  86. Application.DisplayAlerts = True
  87. Application.ScreenUpdating = True
  88. End Sub
½Æ»s¥N½X
¾Ç®üµL²P_¤£®¢¤U°Ý

TOP

¦^´_ 7# luke
ª©¥»ªº°ÝÃD
6#µ{¦¡½X¥H§ó·s ¸Õ¸Õ¬Ý

TOP

¦^´_ 6# GBKEE

    ±a¤J#6·sµ{¦¡«á°õ¦æ¦Ü²Ä12¦C·|¥X²{¤U¦C¿ù»~«H®§

    Error1.jpg

   ¬d¤U¦Cºô§}®É¦³´£¨ì¬°¹ÏªíÅܧó¿ù»~, ¦ý¹ê»Ú¤u§@ªí¤W¨ÃµL¥ô¦ó¹Ïªí
   http://support.microsoft.com/kb/211436/zh-tw  
   
   ¤£ª¾¦¹°ÝÃD¬O§_ÀÉ®×¹L¦h(200~300­ÓÀÉ)³y¦¨
   
   ·Ð½Ð«ü¾É

TOP

¥»©«³Ì«á¥Ñ GBKEE ©ó 2012-6-5 21:34 ½s¿è

¦^´_ 5# luke
  1. Option Explicit
  2. Sub Ex()
  3.     Dim Sh(1 To 2) As Worksheet, Ar, E As Variant, xlCsv As String, xlPath As String
  4.     Dim xi As Integer, xR As Integer, xF As Integer
  5.     xlPath = ThisWorkbook.Path & "\"                                                '->­×§ï¬°¥¿½TªºÀɮ׸ô®|
  6.     Set Sh(1) = Workbooks.Open(xlPath & "test21.csv").Sheets(1)
  7.     Set Sh(2) = Sh(1).Parent.Sheets.Add
  8.     Sh(1).Cells.Copy Sh(2).Cells(1)                                                 '½Æ»s test21.csv ªº¸ê®Æ                          '
  9.     xlCsv = Dir(xlPath & "*.Csv")                                                   '´M§ä *.CsvÀÉ®×
  10.     Do While xlCsv <> "" And LCase(xlCsv) <> "test21.csv"
  11.      With Workbooks.Open(xlPath & xlCsv).Sheets(1)
  12.            Sh(2).Cells(Sh(2).Rows.Count, 1).End(xlUp).Offset(2) = "[*" & xlCsv & "*]"
  13.            .[a1].CurrentRegion.Copy Sh(2).Cells(Sh(2).Rows.Count, 1).End(xlUp).Offset(1)  '½Æ»s *.Csvªº¸ê®Æ
  14.            .Parent.Close 0
  15.      End With
  16.      xlCsv = Dir
  17.     Loop
  18.     Sh(1).Cells.Clear     'test21.csv.Sheets(1) ²M°£©Ò¦³¸ê®Æ: ¤w³Æ­«·s¶×¤J±Æ§Ç«áªº*.Csv
  19.     '*** ³B¸Ì ¤w¶×¤Jªº *.Csv*********
  20.     With Sh(2)
  21.         .Activate
  22.         Ar = .Range("a:a").Value
  23.         .Range("a:a").Replace "[*.*]", "=1/0"                                       '[*.Csv] ´À¥N¬°¿ù»~­È
  24.         .Range("a:a").SpecialCells(xlCellTypeFormulas, xlErrors).Name = "ÀɦW"      '±N¦³¿ù»~­ÈªºÀx¦s®æ ©w¸q¦WºÙ
  25.         .Range("a:a").Value = Ar                                                    '½Æ­ì­ì¨Óªº­È
  26.         With .Columns(Columns.Count)
  27.             [ÀɦW].Copy .Cells(1)
  28.             .Sort Key1:=.Range("a1"), Order1:=xlAscending, Header:=xlGuess          '±Æ§Ç[ÀɦW]
  29.             xR = 1
  30.             Do While .Cells(xR) <> ""                                               '¶×¤J "ÀɦW"¸ê®Æ
  31.                 xF = Application.Match(.Cells(xR), .Parent.Columns(1), 0)           '´M§ä "ÀɦW"
  32.                 xi = Sh(1).Cells(Sh(1).Rows.Count, 1).End(xlUp).Row
  33.                 xi = IIf(xi = 1, 1, xi + 2)                                         '²Ä¤G­Ó[*.Csv]¥H«á ¶·¦A©¹¤U¦ì²¾¨ì2¦C
  34.                 .Parent.Cells(xF, 1).CurrentRegion.Copy Sh(1).Cells(xi, 1)
  35.                 xi = Sh(1).Cells(Sh(1).Rows.Count, 1).End(xlUp).Row
  36.                 Sh(1).Cells(xi + 2, 1) = "[*div*]"
  37.                 xR = xR + 1
  38.             Loop
  39.         End With
  40.         Application.DisplayAlerts = False
  41.         .Delete                                      '§R°£¤u§@ªí
  42.         Application.DisplayAlerts = True
  43.     End With
  44.     '*****´ú¸Õ ¦¨¥\«á ¸Ñ°£µù¸Ñ ¥i¦sÀÉ
  45.     'Sh(1).Parent.Close True
  46. End Sub
½Æ»s¥N½X

TOP

        ÀR«ä¦Û¦b : ¤Ñ¤W³Ì¬ü¬O¬P¬P¡A¤H¥Í³Ì¬ü¬O·Å±¡¡C
ªð¦^¦Cªí ¤W¤@¥DÃD