- ©«¤l
- 1018
- ¥DÃD
- 15
- ºëµØ
- 0
- ¿n¤À
- 1058
- ÂI¦W
- 0
- §@·~¨t²Î
- win7 32bit
- ³nÅ骩¥»
- Office 2016 64-bit
- ¾\ŪÅv
- 50
- ©Ê§O
- ¨k
- ¨Ó¦Û
- ®ç¶é
- µù¥U®É¶¡
- 2012-5-9
- ³Ì«áµn¿ý
- 2022-9-28
|
¥»©«³Ì«á¥Ñ stillfish00 ©ó 2012-12-10 20:20 ½s¿è
¦^´_ 1# fangsc
°Ñ¦Ò¬Ý¬Ý¤U±µ{¦¡ , ¦ý¨ä¹ê¸ê®Æ¶qY¬O«Ü¤jªº¸Ü¤£¬O«Ü«Øijª½±µ¦bWorksheet_Change¨Æ¥ó¤º¥h³B²z- Option Explicit
- Private Sub Worksheet_Change(ByVal Target As Range)
- Dim ws As Worksheet
- Dim r As Long
- Dim sales As String
-
- Application.ScreenUpdating = False
-
- 'clear header
- For Each ws In Sheets
- If not ws is Me Then
- ws.UsedRange.Offset(1).ClearContents
- End If
- Next
-
- For r = 2 To Range("C" & Rows.Count).End(xlUp).Row
- sales = Cells(r, "C").Value
-
- If sales <> "" Then
- If Not hasSheet(sales) Then
- With Sheets.Add(After:=Sheets(Sheets.Count))
- .name = sales
- [A1:H1].Copy .[A1]
- End With
- End If
-
- With Sheets(sales)
- .Range("C" & .Rows.Count).End(xlUp).Offset(1, -2).Resize(1, 8) = Range("A" & r & ":" & "H" & r).Value
- End With
- End If
- Next r
-
- Me.Select
- Application.ScreenUpdating = True
- End Sub
- Function hasSheet(name As String) As Boolean
- Dim ws As Worksheet
-
- On Error Resume Next
- Set ws = Sheets(name)
- On Error GoTo 0
-
- If ws Is Nothing Then
- hasSheet = False
- Else
- hasSheet = True
- End If
-
- Set ws = Nothing
- End Function
½Æ»s¥N½X |
|