|
Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
Dim i%, j%, n%
If Sh.Name <> "信息卡" And Sh.Name <> "封1" And Sh.Name <> "封2" Then
If Sh.Name <> "首页" And Sh.Name <> "查询" And Sh.Name <> "查询结果" Then
If Target.Count > 1 Or Target.Column > 1 Then Exit Sub
Application.Calculation = xlManual '将工作簿设置为手动计算
ActiveSheet.Calculate '将当前工作表及下面几张工作表设置为重新计算
Sheets("信息卡").Calculate
Sheets("封1").Calculate
Sheets("封2").Calculate
Application.EnableEvents = False
If Target.Row > 2 And Target <> "" And Target <> Target.Offset(-1, 0) Then
If [信息卡!i1] <> ActiveSheet.Name Then [信息卡!i1] = ActiveSheet.Name
If [信息卡!h1] <> Target Then [信息卡!h1] = Target
Sheets("信息卡").[a8:a27,c8:c27,d8:d27,e8:e27,f8:f27,g8:g27,h8:h27,c1,c3,c4,c5,e3,e4,e5,g3,g4,g5] = ""
Sheets("封2").[a3:a12,c3:c12,d3:d12,e3:e12,f3:f12,g3:g12] = ""
i = Target.Row
n = 0
For j = i To i + 20
If Range("a" & j) = Target Then
n = n + 1
With Sheets("封2")
.Range("a" & 2 + n) = Year(Range("k" & j))
.Range("c" & 2 + n) = Range("p" & j)
.Range("d" & 2 + n) = Range("l" & j)
.Range("e" & 2 + n) = Range("n" & j)
.Range("f" & 2 + n) = Range("m" & j)
.Range("g" & 2 + n) = (.Range("d" & 2 + n)) + (.Range("e" & 2 + n)) + (.Range("f" & 2 + n))
.Range("e" & 2) = "利息"
End With
End If
Next
[封1!b8] = Year(Range("k" & i)) '解决你在封1中填写初次缴费年、月、日的问题
[封1!d8] = Month(Range("k" & i))
End If
Application.EnableEvents = True
Application.Calculation = xlAutomatic ''将工作簿设置为自动计算
End If
End If
End Sub
请帮我修改代码在封2中实现下面效果:如.Range("f" & 2 + n)小于10就在F2-F12显示Range("m" & j)数据,如果.Range("f" & 2 + n)大于10就在F3-F12显示Range("m" & j)前10个单元格数据,在F16-F25显示Range("m" & j)10以后的单元格数据等,其他以此类推。
[ 本帖最后由 lbl016 于 2010-4-6 20:55 编辑 ] |
|