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

[µo°Ý] 8000¦h­Ó csv Àɪº®æ¦¡­×§ï

[µo°Ý] 8000¦h­Ó csv Àɪº®æ¦¡­×§ï

§Ú¥Ø«e¨C¤Ñ³£¦³ 8000 ¦h­Ó csv Àɮ׻ݭn­×§ï®æ¦¡
¥Ø«e§Úªº¤èªk¬O¼g¤@­Óµ{¦¡¡A¤@­ÓÀɮפ@­ÓÀɮ׶}±Ò­×§ïµM«áÀx¦s
¦ý³o¼Ëªº¤èªk§Úµo²{¦³­Ó°ÝÃD¡A´N¬Oµ{¦¡¥i¯à­×§ï¤F¤­¤»­ÓÀɮ׫á´N·|¦Û¤v°±¤U¨Ó¹y¤@¤U¡A
¹L­Ó´X¬íÄÁ¬Æ¦Ü¤@¤ÀÄÁ¤§«á¤SÄ~Äò¡A¾É­P¾ã­Óµ{¦¡¶]§¹¥i¯à­nªá¦n´X­Ó¤p®É¡C
¥t¥~´N¬O¡A¤£ª¾¹D³o¼Ëªº¾Þ§@¤è¦¡¡A¬O§_·|¼vÅT¨ì¾ã­Ó§@·~¨t²Î¡A¾É­P§@·~¨t²Î·|¦³³\¦h¤p°ÝÃD
½Ðª©¤W¦U¦ì°ª¤â¬O§_¥i¥H«Øij¤ñ¸û¦³®Ä¤Î¥¿½Tªº¤è¦¡¡A¥H¤U¬O§Úªºµ{¦¡½X½Ð°Ñ¦Ò¡AÁÂÁÂ!

Sub ¸ê®ÆÂàÀÉ()

Dim i As Integer
Dim mypath As String
Dim myfile As String
Dim LastRow As Integer
Dim CompanyName As String

Application.ScreenUpdating = False
date = Format(Date, "yyyymmdd")
'date = "20150112" '«ü©w±MÄݤé´Á
mypath = "D:\record\" & date & "\"
myfile = Dir(mypath & "*.csv")

Do While myfile <> ""
    '¶}±ÒÀÉ®×
    Workbooks.Open Filename:=mypath & myfile
   
    With ActiveWorkbook.Sheets(1)
         
        '½Õ¾ã¸ê®Æ®æ¦¡
        CompanyName = CStr(.Cells(2, 2))
        .UsedRange.Rows("1:3").Delete
        .UsedRange.Columns("G:K").Cut
        .Range("A" & .Rows.Count).End(xlUp).Offset(1).Insert Shift:=xlDown
        
        With .UsedRange.Range("A:A")
            
            On Error Resume Next
            .SpecialCells(xlCellTypeBlanks).EntireRow.Delete

        End With
        
        .UsedRange.Sort key1:=.Range("A1"), Order1:=xlAscending, Header:=xlNo
        .UsedRange.Columns(1) = date
        .UsedRange.Columns("B:B").Insert Shift:=xlToRight
               
        For i = 1 To .UsedRange.Rows.Count
            .Cells(i, 3) = Left(.Cells(i, 3), 4)
            .Cells(i, 5) = .Cells(i, 5).Value / 1000
            .Cells(i, 6) = .Cells(i, 6).Value / 1000
        Next
        .UsedRange.NumberFormatLocal = "G/³q¥Î®æ¦¡"
        .UsedRange.Columns("B:B").NumberFormatLocal = "@"
        .UsedRange.Columns(2) = CompanyName
        
        myfile = Dir()
    End With

    'ÀÉ®×Àx¦s«áÃö³¬
    ActiveWorkbook.Close True
    DoEvents

Loop

Application.ScreenUpdating = True

End Sub

¦^´_ 1# sasho
µ½¥Î  On Error Resume Next ¥i¯à¬O¾É­P,­×§ï¤F¤­¤»­ÓÀɮ׫á´N·|¦Û¤v°±¤U¨Ó¹y¤@¤U¡A
¹L­Ó´X¬íÄÁ¬Æ¦Ü¤@¤ÀÄÁ¤§«á¤SÄ~Äò¡A¾É­P¾ã­Óµ{¦¡¶]§¹¥i¯à­nªá¦n´X­Ó¤p®É¡Cªº¥D¦]
  1. With .UsedRange.Range("A:A")            
  2.             On Error Resume Next
  3.             .SpecialCells(xlCellTypeBlanks).EntireRow.Delete
  4.         End With
  5.         '***¤U­±¦³±Æ§Çªº°Ê§@,¤W­±ªº.Delete¦ü¥G¬O¦h¾lªº ****
  6.         .UsedRange.Sort key1:=.Range("A1"), Order1:=xlAscending, Header:=xlNo
  7.         .UsedRange.Columns(1) = date
  8.         .UsedRange.Columns("B:B").Insert Shift:=xlToRight               
½Æ»s¥N½X
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

¥»©«³Ì«á¥Ñ stillfish00 ©ó 2015-3-9 10:09 ½s¿è

¦^´_ 1# sasho
  1. date = Format(Date, "yyyymmdd")
½Æ»s¥N½X
date ¬O«O¯d¦r¡A¤£­n®³¨Ó©R¦WÅܼơA³o¼Ë¼gÀ³¸Ó·|¥X¿ù§a¡C
  1.         .UsedRange.Columns("G:K").Cut
  2.         .Range("A" & .Rows.Count).End(xlUp).Offset(1).Insert Shift:=xlDown
½Æ»s¥N½X
ÁÙ¬OªþÀɧa¡A¬Ý¤£À´­n·F¹À¡AG:K°Å¤U«á´¡¤J¨ì???
°ò¥»¤W³o¼Ë¼g·|¥X¿ù
  1.             On Error Resume Next
  2.             .SpecialCells(xlCellTypeBlanks).EntireRow.Delete
½Æ»s¥N½X
On Error Resume Next¤£­n³o¼Ë¥Î
  1.         For i = 1 To .UsedRange.Rows.Count
  2.             .Cells(i, 3) = Left(.Cells(i, 3), 4)
  3.             .Cells(i, 5) = .Cells(i, 5).Value / 1000
  4.             .Cells(i, 6) = .Cells(i, 6).Value / 1000
  5.         Next
½Æ»s¥N½X
¦C¼Æ«Ü¦hªº¸Ü¡A¥i¥H¤@¦¸´£¨ìarray³B²z§¹¦A¤@¦¸¼g¦^
ªí¹F¤£²M¡BÃD·N¤£©ú½T¡B¨SªþÀɮ׮榡¡B¨S¦³°Q½×°ÝÃDªººA«×~~~~~~¥H¤W·R²ö¯à§U¡C

TOP

·PÁ¨â¦ì°ª¤â«üÂI¡A§Ú«á¨Ó¦³­×§ï¤F¤@¤Uµ{¦¡
µo²{°ÝÃD¨ä¹ê¨Ã¤£¦b­×§ï®æ¦¡ªºµ{¦¡½X¤¤
¦Ó¬O¦b¨C¦¸¶}¶}ÃöÃöÀɮתº¹Lµ{

¤£Â_ªº¶}¶}ÃöÃö¾É­P§Ú¦b¸ê®Æ§¨
C:\Users\XXXXX\AppData\Roaming\Microsoft\Office\recent
«Ø¥ß¤F´X¸U­Ó±¶®|!

¨C¦¸¶}±Ò¤@­Ó excel ÀɮסA¨t²Î´N·|¦Û°Ê¯d¦s¤@µ§¸ê®Æ
¤U¦¸­n¦A¶}°_ªº®É­Ô¡A´N¥i¥Hª½±µ¨ìÀÉ®× -> ³Ìªñ ªº²M³æ¤¤ÂI¿ï
¦Ó³o­Ó¸ê®Æ§¨¤¤ªº±¶®|´N¬O³o¨ÇÀɮתº³sµ²

©Ò¥H§Ú·Q¡A¦pªG¬O­n¶}¶}ÃöÃö EXCEL Àɮתº¸Ü¡A¥i¯à¬O¨S¸Ñ¤F
¤£¾å±o¦U¦ì°ª¤â¬O§_¥i¥H«Øij¸Ó¦p¦ó±N .CSV ªº¸ê®ÆŪ¨ú«á­×§ï­ì¥»ªºÀɮשO?
¥Ø«e google ¨ìªº³£¥u¦³¼g¤J ©Î ¿é¥X ¤À§Oªº¤èªk¡A
¥B¤j³¡¤À³£¬O´`§ÇŪ¨ú¡A¦³¿ìªk¤@¦¸±N¾ã­Ó¤å¥»Åª¨ì°O¾ÐÅ餤°µ³B²z¶Ü?

¥ý¦V¦U¦ì°ª¤â­PÁ©Ô~~

TOP

        ÀR«ä¦Û¦b : ¦³Ä@©ñ¦b¤ß¸Ì¡A¨S¦³¨­Åé¤O¦æ¡A¥¿¦p¯Ñ¥Ð¤£¼½ºØ¡A¬Ò¬OªÅ¹L¦]½t¡C
ªð¦^¦Cªí ¤W¤@¥DÃD