- ©«¤l
- 913
- ¥DÃD
- 150
- ºëµØ
- 0
- ¿n¤À
- 1089
- ÂI¦W
- 0
- §@·~¨t²Î
- win10
- ³nÅ骩¥»
- office 2019
- ¾\ŪÅv
- 50
- ©Ê§O
- ¤k
- µù¥U®É¶¡
- 2011-8-28
- ³Ì«áµn¿ý
- 2023-7-19
|
¦^´_ 38# oobird
¦^´_ 35# Hsieh
¦Ñ¤j,½Ð°Ý§A¬O§_¦^µª§Ú²Ä37¼Óªº°ÝÃD?Y¬Oªº¸Ü:
Âk¨s°_¨Ó¬OÀɮפӦh¤£¦P®æ¦¡©Ò³y¦¨ªº°ÝÃD,Y¬OTOTALªº°ÝÃD,§Ú·Q«Ü¦hÄæ¦ì³£·|¥Î³oÓ¦r,Y§Ú²Î¤@¥u±Ä¥Î"TOTAL:"(¬O¦³«_¸¹ªº),«h¥H¤U³o2Óµ{¦¡¤W§ÚÀ³¸Ó¦p¦óקï?¸Ó¥¦¥u¦b¬Ý¨ì"TOTAL:"ªº±¡§Î¤U¤~§@°Ê§@?(¤GÓµ{¦¡¦U¦³¥¦¦n¥Î¥Îªº¦a¤è,§Ú³£·Qק復)- Sub get_value()
- Dim Sh As Worksheet, a As Range, Ar(), B As Range, B1 As Range
- Set d = CreateObject("Scripting.Dictionary")
- Application.ScreenUpdating = False
- Application.DisplayAlerts = False
- fd = ThisWorkbook.Path & "\" & "2011 PI_PO\"
- fs = Dir(fd & "*xls*")
- Do Until fs = ""
- With Workbooks.Open(Filename:=fd & fs, UpdateLinks:=False)
- n = Split(fs, " ")(0)
- s = InStr(n, "BCM") + 3
- fn = Mid(n, s)
- For Each Sh In .Sheets
- With Sh
- If Trim(.Name) <> "PO" And Trim(.Name) <> "PI" Then GoTo 10
- For Each c In .Range("A:B").SpecialCells(xlCellTypeConstants)
- If c Like "TOTAL*" Then Set a = c: Exit For
- Next
- If Not a Is Nothing Then
- Set B = a.EntireRow.Find("pcs")
- Set B1 = a.EntireRow.Find("*", after:=B)
-
- If Not B Is Nothing Then
- d(Trim(.Name) & "¼Æ¶q") = B.Offset(, -1)
- c1 = a.EntireRow.Find("*", after:=B1)
- d(Trim(.Name) & "ª÷ÃB") = c1
- End If
- End If
- Set a = Nothing
- End With
- 10
- Next
- ReDim Preserve Ar(y)
- Ar(y) = Array(fn, d("PI¼Æ¶q"), d("PIª÷ÃB"), d("PO¼Æ¶q"), d("POª÷ÃB"), fs)
- y = y + 1
- .Close
- d.RemoveAll
- End With
- fs = Dir
- Loop
- Sheets("Records").[A2].Resize(y, 6) = Application.Transpose(Application.Transpose(Ar))
- Application.ScreenUpdating = True
- Application.DisplayAlerts = True
- End Sub
½Æ»s¥N½X- Sub get_value_F()
- Dim a As Range, arr(1 To 5)
- Application.ScreenUpdating = False 'Ãö³¬¿Ã¹õ°{Ã{
- For Each a In Range([f2], [f2].End(4)) '¦bf2¥H¤Uªº¸ê®Æ½d³ò´`Àô
- If Application.CountA(Rows(a.Row)) = 1 Then 'a:eÄæ¤w¦³¼g¤J¸ê®Æ´N¸õ¹L
- Application.DisplayAlerts = False 'Ãö³¬¶}±Ò®Éªº¹ï¸Ü¤è¶ô
- fb = ThisWorkbook.Path & "\2011 PI_PO\" & a '±q"PI_PO¸ê®Æ§¨"¨ú¸ô®|
- Set wk = GetObject(fb) 'I´º¶}±Ò¸Ó¸ô®|ÀÉ®×
- Sh = Array("PI", "PO") '¨âÓ¤u§@ªí¦W
- On Error Resume Next '²¤¹L¿ù»~
- For s = 0 To 1
- Set mysheet = wk.Sheets(Sh(s)) '¤u§@ªíÅܶq
- If Err.Number = 0 Then '¦p¤£µo¥Í¿ù»~(¦³³oÓ¤u§@ªí)
- mysheet.AutoFilterMode = False '¨ú®ø¿z¿ï
- mysheet.[a:b].Replace "TOTAL:", "TOTAL", xlWhole '§â±a¤À¸¹ªºTOTAL§ï¦¨¤£±a¤À¸¹
- r = mysheet.[a:b].Find("TOTAL", , , 1, xlByRows).Row '¦bAB¨âÄæ´M§ä"TOTAL"
- c = mysheet.Cells(r, 15).End(1).Column '¨úTOTAL¨º¤@¦æªº³Ì¥kÄæ(§Yª÷ÃB)
- arr(1) = Split(a, " ")(0) '¨úfÄæ²Ä¤@ӪŮæ¥H«eªº¦r¦ê
- arr(s * 2 + 2) = mysheet.Cells(r, c - 3).Value '¨ú³Ì¥kÄæ´î3Ä檺¼Æ¦r
- arr(s * 2 + 3) = mysheet.Cells(r, c).Value '¨ú³Ì¥kÄ檺¼Æ¦r
- End If
- Err.Clear '²M°£¿ù»~
- Next
- Cells(a.Row, 1).Resize(1, 5) = arr '¼g¤JÀx¦s®æ
- Erase arr
- wk.Close 0 'Ãö³¬¥´¶}ªºÀɮפ£Àx¦s
- End If
- Next
- End Sub
½Æ»s¥N½X |
|