- ©«¤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 ©ó 2014-8-16 11:50 ½s¿è
¦^´_ 6# bridetobe
¸Õ¸Õ¬Ý- Option Explicit
- Sub Ū¥X()
- Dim a_date, Rng(1 To 2) As Range
- Application.Calculation = xlCalculationManual '¤â°Êpºâ
- Application.StatusBar = False
- With Sheets("¾Þ§@")
- Set Rng(1) = .[A2:F2]
- Set Rng(2) = .Cells(1, .Columns.Count)
- .Range(Rng(1)(2, 1), Rng(1).End(xlDown)).Resize(, 7) = ""
- .[B1].Value = InputBox("¿é¤J¤é´Á(¨Ò2014/7/1):", , "2014/7/1")
- Rng(2) = "¤é´Á"
- Rng(2).Offset(1) = .[B1]
- 'AdvancedFilter ¶i¶¥¿z¿ï
- '¶i¶¥¿z¿ï:ªº·Ç«h½d³ò -> Rng(2).Resize(2)
- Sheets("¦s³f¸ê®Æ").UsedRange.AdvancedFilter xlFilterCopy, Rng(2).Resize(2), Rng(1)
- Rng(2).EntireColumn = ""
- If Rng(1).End(xlDown).Row <> .Rows.Count Then
- Set Rng(2) = Rng(1).Cells(2, 1)
- Do While Rng(2) <> ""
- Rng(2).Cells(1, "G") = ¤W¤@Ó¤pp(.[B1], Rng(2).Text) - Rng(2).Cells(1, "F")
- If Rng(2).Cells(1, "G") < 0 Then Rng(2).Cells(1, "G") = 0
- Set Rng(2) = Rng(2).Cells(2)
- Loop
- MsgBox "Ok"
- Else
- MsgBox "¨S¦³¸ê®Æ"
- End If
- End With
- ' Application.Calculation = xlAutomatic '¦Û°Êpºâ
- '¦Û°Ê¿z¿ï«á·|¦³¤u§@ªí«ºâªº°Ê§@,µ{¦¡·|µ¥Ô«ºâ§¹²¦,¦AÄ~Äò°õ¦æ¤U¥h.
- End Sub
- 'AutoFilter: ¦Û°Ê¿z¿ï
- Private Function ¤W¤@Ó¤pp(¤é´Á As String, «~¦W As String) As Integer
- Dim Rng As Range
- With Sheets("¦s³f¸ê®Æ").UsedRange
- '¦Û°Êpºâ:·í¦Û°Ê¿z¿ï«á·|¦³¤u§@ªí«ºâªº°Ê§@,¼vÅTµ{¦¡°õ¦æªº³t«×
- '¦Û°Ê¿z¿ï «ü©wÄæ¦ì,·Ç«h
- .AutoFilter 1, ">" & ¤é´Á
- .AutoFilter 2, "=" & «~¦W
- Set Rng = .SpecialCells(xlCellTypeVisible)
- If Rng.Areas(1).Rows.Count > 1 Then
- ¤W¤@Ó¤pp = Rng.Areas(1).Cells(2, "g")
- Else
- ¤W¤@Ó¤pp = Rng.Areas(2).Cells(1, "g")
- End If
- End With
- End Function
½Æ»s¥N½X |
|