|
本帖最后由 todaynew 于 2013-8-4 12:10 编辑
Private Sub Worksheet_Change(ByVal Target As Range)
Select Case Target
Case Cells(2, 6)
Call 遍历数据(Target, 1)
Case Cells(4, 6)
Call 遍历数据(Target, 2)
Case Cells(6, 6)
Call 遍历数据(Target, 3)
End Select
End Sub
Private Sub 遍历数据(ByVal Target As Range, ByVal m As Integer)
Dim r As Range
Dim Area1 As Range, Area2 As Range
Dim i As Integer
Dim x1 As Integer, y1 As Integer
Dim x2 As Integer, y2 As Integer
Set r = Range("Data") '数据区域
Set Area1 = Range("Area" & m & "1") '党员区域
Set Area2 = Range("Area" & m & "2") '团员区域
x1 = 1: y1 = 1
x2 = 1: y2 = 1
For i = 1 To r.Rows.Count
If r.Cells(i, 1).Text = Target.Text Then
Select Case r.Cells(i, 3).Text
Case "党员"
Area1.Cells(x1, y1) = r.Cells(i, 2).Text
y1 = y1 + 1
If y1 > Area1.Columns.Count Then
x1 = x1 + 1
y1 = 1
End If
Case "团员"
Area2.Cells(x2, y2) = r.Cells(i, 2).Text
y2 = y2 + 1
If y2 > Area2.Columns.Count Then
x2 = x2 + 1
y2 = 1
End If
End Select
End If
Next
End Sub
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?注册
x
|