|
先看下27楼的内容
先大概来个思路(有些情况下会出错,怎么处理还没想好)
不知对不,但感觉就该这么解决这种问题
Sub abc()
Dim x%, y%
ar1 = Range("a2:ae32")
For x = 29 To 2 Step -1
For y = 30 To 2 Step -1
If ar1(x, y) <> "" Then
ar1(x, y) = ar1(x + 1, y) + ar1(x, y + 1)
If ar1(x + 1, y) <> "" And ar1(x, y - 1) <> "" And ar1(x, y + 1) <> "" Then ar1(x, y) = 0
End If
Next y
Next x
Range("a2:ae32") = ar1
[b2].Select
Selection.Interior.ColorIndex = 33
Do While Selection.Offset(0, 1) = "" Or Selection.Offset(0, 1) = Selection.Offset(1, 0) And Selection.Offset(1, 0) <> ""
Selection.Offset(1, 0).Select
Selection.Interior.ColorIndex = 33
Loop
If Selection.Offset(1, 0) <> "" And Selection.Offset(0, 1) <> "" Then
If Selection.Offset(1, 0) < Selection.Offset(0, 1) Then
Selection.Offset(1, 0).Select
Else
Selection.Offset(1, 0).Select
End If
ElseIf Selection.Offset(1, 0) <> "" Then
Selection.Offset(1, 0).Select
ElseIf Selection.Offset(0, 1) <> "" Then
Selection.Offset(0, 1).Select
End If
Selection.Interior.ColorIndex = 33
Do While Selection.Row < 31
If Selection.Offset(1, 0) <> "" And Selection.Offset(0, 1) <> "" Then
If Selection.Offset(1, 0) > Selection.Offset(0, 1) Then
Selection.Offset(1, 0).Select
Else
Selection.Offset(0, 1).Select
End If
ElseIf Selection.Offset(1, 0) <> "" Then
Selection.Offset(1, 0).Select
ElseIf Selection.Offset(0, 1) <> "" Then
Selection.Offset(0, 1).Select
End If
Selection.Interior.ColorIndex = 33
Loop
End Sub
[ 本帖最后由 HHAAMM 于 2008-11-7 13:00 编辑 ] |
|