- ©«¤l
- 522
- ¥DÃD
- 36
- ºëµØ
- 1
- ¿n¤À
- 603
- ÂI¦W
- 0
- §@·~¨t²Î
- win xp sp3
- ³nÅ骩¥»
- Office 2003
- ¾\ŪÅv
- 50
- ©Ê§O
- ¨k
- µù¥U®É¶¡
- 2012-12-13
- ³Ì«áµn¿ý
- 2021-7-11
|
¸Õ¸Õ¬Ý:
VBA code:
Option Explicit
Sub ²M°£¸ê®Æ()
Dim i, msg As Integer, x, sh As Worksheet
Set x = Sheets("¿é¤J")
Application.DisplayAlerts = False
'Y±N¤u§@¶©R¦W¬° "¿é¤J","¾ú¥v","¼t°ÓÃþ","û¤uÃþ","¤½¥qÃþ","¼t°ÓÃþ(1)","¼t°ÓÃþ(2)",...
'«h¥i¨Ì Len(Sh.Name) ¨M©w Delete ©Î Clearcontents
For Each sh In Sheets
If Len(sh.Name) > 3 Then
sh.Delete
ElseIf Len(sh.Name) = 3 Then
sh.Range("A2:E11").ClearContents
End If
Next
'²M°£¿z¿ï°Ïªº¸ê®Æ
x.Range("G:K").Clear
'¬O§_²M°£¿é¤J°Ïªº¸ê®Æ?
msg = MsgBox("n²M°£¿é¤J°Ïªº¸ê®Æ¶Ü?", vbYesNo)
If msg = vbYes Then
x.Range("A2:E" & x.UsedRange.Rows.Count).ClearContents
End If
End Sub
Sub ¦s¤J¾ú¥v¬ö¿ý()
Dim i, msg As Integer, sh, x, y As Worksheet
Dim ¤é´Á, ·s¤é´Á As Date
Set x = Sheets("¿é¤J")
Set y = Sheets("¾ú¥v")
Application.ScreenUpdating = False
'¦pªG©|¥¼¦³¾ú¥v¬ö¿ý(²Ä¤@¦¸), ±q "¿é¤J" ½Æ»s¨ì "¾ú¥v" (§t¼ÐÀY)
If y.UsedRange.Rows.Count = 1 Then
x.Range("A1:E" & x.UsedRange.Rows.Count).Copy
y.Range("A1").PasteSpecial xlPasteValues
Else
¤é´Á = y.Range("A" & y.UsedRange.Rows.Count)
·s¤é´Á = x.Range("A" & x.UsedRange.Rows.Count)
'ª`·N¡G"¿é¤J"¶ AÄæ(§Y¤é´ÁÄæ), À³³]©w ¸ê®ÆÅçµý, ¨Ã³]¬° "¤é´Á",
'§_«h If ¤é´Á < ·s¤é´Á Then ·|§PÂ_¿ù»~!!
'±q "¿é¤J"¶ ½Æ»s¨ì "¾ú¥v"¶ (¤£§t¼ÐÀY, ¥BªÅ2¦C)
If ¤é´Á < ·s¤é´Á Then
x.Range("A2:E" & x.UsedRange.Rows.Count).Copy
y.Range("A" & y.UsedRange.Rows.Count + 3).PasteSpecial xlPasteValues
Else
msg = MsgBox(DateValue(·s¤é´Á) & " ¤w¸g¦s¹L¤F!!", vbOKOnly)
End If
End If
Application.ScreenUpdating = True
End Sub
Sub ¿z¿ï¸ê®Æ()
Dim i, UsedRow As Integer, x, sh, shOld As Worksheet
Dim shName
shName = Array("¼t°ÓÃþ", "¤½¥qÃþ", "û¤uÃþ")
Set x = Sheets("¿é¤J")
Application.DisplayAlerts = False
Application.ScreenUpdating = False
'¦]¬° "¼t°ÓÃþ"¡B"¤½¥qÃþ"¡B"û¤uÃþ" ¥u¦³¨C¤Ñ¨Ï¥Î¡A
'¦C¦L«á´N¥i¥H²MªÅ¸ê®Æ, ¬GÀ³¨Ì "¿é¤J" ¿z¿ï, ¦Ó¤£¬O¨Ì "¾ú¥v"
For i = 0 To 2
Set sh = Sheets(shName(i))
x.Activate
'±N¶i¶¥¿z¿ïªº ¿z¿ï·Ç«h ¶ñ¤J x.[F3]
x.[F3] = Left(shName(i), 2)
'¶i¶¥¿z¿ï A:EÄæ «½Æ¸ê®Æ¨ì "G1" ***´ú¸Õ¥Î(¦hµ§«½Æ)***
x.Range("A1:E" & x.UsedRange.Rows.Count).AdvancedFilter xlFilterCopy, x.Range("F2:F3"), x.Range("G1:K1"), False
'¶i¶¥¿z¿ï A:EÄæ ¤£«½Æ¸ê®Æ¨ì "G1" ***¹ê»Ú¥Î(¤£«½Æ)***
'x.Range("A1:E" & x.UsedRange.Rows.Count).AdvancedFilter xlFilterCopy, x.Range("F2:F3"), x.Range("G1:K1"), True
'±N ¿z¿ïµ²ªG ½Æ»s¨ì¹ïÀ³ªºÃþ§O¤u§@ªí
x.Range("G:K").Copy
sh.[A1].PasteSpecial xlPasteValues
Do While sh.[A12] <> "" 'ª½¨ì¹ïÀ³ªºÃþ§O¤u§@ªí[A12] = ""
sh.Copy After:=Sheets(Sheets.Count) '1 ½Æ»sì¤u§@ªí
sh.Rows("12:" & sh.Rows.Count).Delete '2 ±Nì¤u§@ªí12¦C¥H¤U§R°£(«O¯d10¦C)
Set shOld = sh '3 ±N shOld ³]µ¹ì¤u§@ªí
Set sh = Sheets(Sheets.Count) '4 ±N sh ³]µ¹·s¤u§@ªí
sh.Rows("2:11").Delete '5 §R°£·s¤u§@ªí 2:11 ¦C
shOld.[A1:E11].Copy '6 ½Æ»sì¤u§@ªíªº ®æ¦¡ ¨ì·s¤u§@ªí
sh.[A1].PasteSpecial xlPasteFormats
Loop
Next
Application.ScreenUpdating = True
End Sub |
|