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

[µo°Ý] ¦p¦ó¦b¦h­ÓexcelÀɤ¤§ä¥X¸ê®Æ¡AµM«á¦b¦P¤@­ÓÀɤ¤±Æ§Ç

[µo°Ý] ¦p¦ó¦b¦h­ÓexcelÀɤ¤§ä¥X¸ê®Æ¡AµM«á¦b¦P¤@­ÓÀɤ¤±Æ§Ç

¥»©«³Ì«á¥Ñ eternal001 ©ó 2011-8-1 20:57 ½s¿è

°²³]¦³«Ü¦h­ÓexcelÀÉ
11.JPG 22.JPG
­n¦b¥t¤@­ÓÀɮפ¤§ä¨ì³o¨ÇÀɮתºÁ`¥­§¡
¨C¤@­ÓÀɤ¤
¥L­Ì¾Ö¦³ªº¬ì¥Ø¤£¤@©w¤@¼Ë¦h
¥u¬O³Ì«á³£·|¦³¤@­ÓÁ`¥­§¡­È
¥L­Ìªº¦W¦r´N¬OÀɦW
µM«á¦b¥t¤@­ÓÀɱƧǥL­Ìªº¦W¦¸
33.JPG
¦]¬°¸ê®Æ¦³¤W¤dµ§
©Ò¥H¤£ª¾­n«ç»ò¥h§ì¸ê®Æ±Æ§Ç

½Ð°ª¤âÀ°¦£¸Ñµª

¦hµ§¸ê®Æ±Æ§Ç.rar (18.33 KB)

¥»©«³Ì«á¥Ñ luhpro ©ó 2011-8-1 23:01 ½s¿è

¦^´_ 1# eternal001
  1. Private Sub cbLoad_Click()
  2.   Dim lRow As Long, lCount As Long
  3.   Dim sPath$, sFName$, sName$, sTheName$
  4.   Dim bTranFile As Boolean
  5.   Dim vSou
  6.   
  7.   sPath = ThisWorkbook.Path    ' «ü©w¸ô®|¬°¥»ÀɮשҦbªºªº¥Ø¿ý
  8.   bTranFile = False ' ¬ö¿ý¬O§_¦³Åª¨ìÀÉ®×
  9.   With Me ' ¥» Sheet §Y Sheet1
  10.     .Cells.Clear ' ²M¸ê®Æ
  11.     .Cells(1, 1) = "±Æ¦W" ' ¼ÐÃD
  12.     .Cells(1, 2) = "¤H¦W"
  13.     .Cells(1, 3) = "Á`¤À"
  14.     lRow = 2 ' ±q²Ä¤G¦C¶}©l©ñ¸ê®Æ
  15.     lCount = 0 ' Ū¨ú¸ê®ÆÀɮ׼ƶq
  16.     sTheName = Me.Parent.Name ' ¥»Àɮתº¥Ø¿ý
  17.     sFName = Dir(sPath & "\*.xls")   ' §ä´M²Ä¤@­ÓExcelÀÉ®×
  18.     Do While sFName <> ""    ' °õ¦æ°j°é¡C
  19.       If sFName <> sTheName Then ' ¸õ¹L¥»ÀÉ®×
  20.         bTranFile = True
  21.         sName = Left(sFName, Len(sFName) - 4) ' ºI¨ú¤H¦W
  22.         sFName = sPath & "\" & sFName ' ÀÉ®×¥þ¦W
  23.         Workbooks.Open Filename:=sFName, ReadOnly:=True ' ¶}ÀÉ
  24.         Set vSou = ActiveWorkbook.Sheets(1) '³]©w Sheet(1) ª«¥óµ¹ vSou
  25.         Workbooks(sTheName).Activate ' µJÂI¤Á¦^­ìSheet
  26.         .Cells(lRow, 1) = lRow - 1 ' ±Æ¦W
  27.         .Cells(lRow, 2) = sName '¤H¦W
  28.         .Cells(lRow, 3) = Round(vSou.Cells(vSou.Cells(1, 1). _
  29.                           CurrentRegion.Find("Á`¥­§¡").Row, 2)) 'Á`¤À
  30.         lRow = lRow + 1 ' ¦C¸¹ + 1
  31.         lCount = lCount + 1 ' Ū¨úÀÉ®×¼Æ + 1
  32.       End If
  33.       If sFName <> sTheName Then Workbooks(sName & ".xls").Close ' Ãö³¬¥»ÀÉ®×¥H¥~¶}±ÒªºÀÉ®×
  34.       sFName = Dir    ' ´M§ä¤U¤@­ÓÀÉ®×
  35.     Loop
  36.     .Range(.Cells(2, 2), .Cells(lRow, 3)).Sort Key1:=.Cells(1, 3), order1:=xlDescending ' ¥HÁ`¤À¬°Áä­È°µ±Æ§Ç
  37.   End With
  38.   
  39.   If Not bTranFile Then
  40.     MsgBox ("§ä¤£¨ì¥ô¦ó¸ê®ÆÀÉ®×...")
  41.     Exit Sub
  42.   Else
  43.     MsgBox ("¸ê®ÆŪ¨ú§¹¦¨, ¦@Ū¨ú " & lCount & " ­ÓÀÉ®×...")
  44.     Exit Sub
  45.   End If
  46. End Sub
½Æ»s¥N½X
±Æ§Ç-A.zip (13.08 KB)

TOP

¦^´_ 2# luhpro
­×§ï§Aªºµ{§Ç½Ð°Ñ¦Ò°Ñ¦Ò
  1. Sub Ex()
  2.     Dim Ar(), S As Integer, sPath As String, sFName As String
  3.     ReDim Ar(1, S)
  4.     sPath = ThisWorkbook.Path    ' «ü©w¸ô®|¬°¥»ÀɮשҦbªºªº¥Ø¿ý
  5.     sFName = Dir(sPath & "\*.xls")   ' §ä´M²Ä¤@­ÓExcelÀÉ®×
  6.     Do While sFName <> ""    ' °õ¦æ°j°é¡C
  7.         If sFName <> ThisWorkbook.Name Then  ' ¶}±Ò¥»ÀÉ®×¥H¥~ªºÀÉ®×
  8.             ReDim Preserve Ar(1, S)
  9.             With Workbooks.Open(sPath & "\" & sFName) ' ¶}ÀÉ
  10.                 With .Sheets(1).Cells.Find("Á`¥­§¡")
  11.                     Ar(0, S) = Mid(sFName, 1, InStrRev(sFName, ".") - 1)
  12.                     Ar(1, S) = Cells(1, 2)
  13.                 End With
  14.                 .Close
  15.             End With
  16.             S = S + 1
  17.         End If
  18.         sFName = Dir    ' ´M§ä¤U¤@­ÓÀÉ®×
  19.     Loop
  20.     Range("A:C") = ""
  21.     Range("A1:C1") = Array("±Æ¦W", "¤H¦W", "Á`¥­§¡")
  22.     Range("B2").Resize(S, 2) = Ar
  23.     Range("A1").CurrentRegion.Sort Key1:=Range("C2"), Order1:=xlAscending, Header:=xlYes
  24.     With Range("A2:A" & Range("B2").End(xlDown).Row)
  25.         .Value = "ROW()-1"
  26.         .Value = .Value
  27.     End With
  28.   If S = 0 Then
  29.     MsgBox ("§ä¤£¨ì¥ô¦ó¸ê®ÆÀÉ®×...")
  30.   Else
  31.     MsgBox ("¸ê®ÆŪ¨ú§¹¦¨, ¦@Ū¨ú " & S - 1 & " ­ÓÀÉ®×...")
  32.   End If
  33. End Sub
½Æ»s¥N½X

TOP

        ÀR«ä¦Û¦b : §Ú­Ì³Ì¤jªº¼Ä¤H¤£¬O§O¤H¡D¥i¯à¬O¦Û¤v¡C
ªð¦^¦Cªí ¤W¤@¥DÃD