|
我是一个VBA小白,别人做的表,但是用不了,请大神完善。有谢!
Sub XX5()
Dim Rng As Range, Rng0 As Range, Rng1 As Range
Dim C_str$, C_T$, C_L$
Dim arr, Xarr()
Dim iMax%, i%
J = Sheet2.[A2:A60000].Find(Sheet2.[I1], , , , , 2).Row
If Sheet2.Range("B" & J) = "" Then
MsgBox "您本次选择的期号还未输入开奖号码,请检查并重新设置起始期号"
Exit Sub
End If
Dim p As Shape
Set My = Worksheets("自选100期范围内排五走势图")
For Each p In My.Shapes
If Not Application.Intersect(p.TopLeftCell, Range("G4:BD201")) Is Nothing Then p.Delete
Next
Range("A4:BD201").ClearContents
[B3] = "正在画线中"
With Sheet2
arr = .Range("A" & J, "F" & J + 99)
End With
ReDim Xarr(1 To 100, 1 To 6 + 5 * 10)
For i = 1 To 100
Xarr(i, 1) = arr(i, 1)
Xarr(i, 2) = arr(i, 2)
Xarr(i, 3) = arr(i, 3)
Xarr(i, 4) = arr(i, 4)
Xarr(i, 5) = arr(i, 5)
Xarr(i, 6) = arr(i, 6)
Xarr(i, 6 + arr(i, 2) + 1) = arr(i, 2)
Xarr(i, 6 + 10 + arr(i, 3) + 1) = arr(i, 3)
Xarr(i, 6 + 20 + arr(i, 4) + 1) = arr(i, 4)
Xarr(i, 6 + 30 + arr(i, 5) + 1) = arr(i, 5)
Xarr(i, 6 + 40 + arr(i, 6) + 1) = arr(i, 6)
Next
[A4].Resize(100, 56) = Xarr
For M = 1 To 5
Select Case M
Case 1
C_str = "G2:P" & [A65536].End(xlUp).Row
C_T = "G"
C_L = "P"
Case 2
C_str = "Q2:Z" & [A65536].End(xlUp).Row
C_T = "Q"
C_L = "Z"
Case 3
C_str = "AA2:AJ" & [A65536].End(xlUp).Row
C_T = "AA"
C_L = "AJ"
Case 4
C_str = "AK2:AT" & [A65536].End(xlUp).Row
C_T = "AK"
C_L = "AT"
Case 5
C_str = "AU2:BD" & [A65536].End(xlUp).Row
C_T = "AU"
C_L = "BD"
End Select
Set Rng = Range(C_str).SpecialCells(xlCellTypeConstants, 1)
For Each Rng0 In Rng
F_Address = Rng0.Address
For Each Rng1 In Range(C_T & Rng0.Row & ":" & C_L & [A65536].End(xlUp).Row).SpecialCells(xlCellTypeConstants, 1)
If F_Address <> Rng1.Address Then
Call myLine(Rng0, Rng1)
Exit For
End If
Next
Next
C_str = ""
C_T = ""
C_L = ""
Next
[B3] = "完成"
[B3].Select
End Sub
Sub myLine(Cel0 As Range, Cel1)
x0 = Cel0.Left + Cel0.Width / 2
y0 = Cel0.Top + Cel0.Height / 2
X1 = Cel1.Left + Cel1.Width / 2
y1 = Cel1.Top + Cel1.Height / 2
ActiveSheet.Shapes.AddLine(x0, y0, X1, y1).Select
Selection.ShapeRange.Line.ForeColor.SchemeColor = 2
End Sub
Sub SC()
Dim p As Shape
Set My = Worksheets("自选100期范围内排五走势图")
For Each p In My.Shapes
If Not Application.Intersect(p.TopLeftCell, Range("G4:BD201")) Is Nothing Then p.Delete
Next
Range("A4:BD201").ClearContents
End Sub
本人QQ,55150607
|
|