VBA程序执行结果有时候不对,美女帅哥帮我分析下
Sub test()
Dim r1 As Range, r2 As Range
Dim p, q
'ActiveSheet.DrawingObjects.Select
'MsgBox Sheet9.Cells(1, 4).Value
For i = 1 To 15
[a:i].HorizontalAlignment = xlCenter
For j = 5 To 13
If Trim(Sheet9.Cells(i, j)) <> "" Then
p = Sheet9.Cells(i, j).Value
' MsgBox (p)
Set r1 = Rows(i).Find(p)
End If
If Trim(Sheet9.Cells(i + 1, j)) <> "" Then
q = Sheet9.Cells(i + 1, j).Value
'MsgBox (q)
Set r2 = Rows(i + 1).Find(q)
End If
Next
ActiveSheet.Shapes.AddLine r1.Left + r1.Width * 0.5, r1.Top + r1.Height * 0.7, r2.Left + r2.Width * 0.5, r2.Top + r2.Height * 0.3
Next
End Sub
每行有一个数据,将数据用线条连接起来,跟3D走势图类似
[解决办法]
不是美女不是帅哥的问一下
哪里不对,怎么不对?
[解决办法]
- VB code
Sub test() Dim r1 As Range, r2 As Range Dim p, q 'ActiveSheet.DrawingObjects.Select 'MsgBox Sheet9.Cells(1, 4).Value For i = 1 To 5 [a:i].HorizontalAlignment = xlCenter If Trim(Sheet1.Cells(i, i)) <> "" Then p = Sheet1.Cells(i, i).Value ' MsgBox (p) Set r1 = Rows(i).Find(p) End If If Trim(Sheet1.Cells(i + 1, i + 1)) <> "" Then q = Sheet1.Cells(i + 1, i + 1).Value 'MsgBox (q) Set r2 = Rows(i + 1).Find(q) End If ActiveSheet.Shapes.AddLine r1.Left + r1.Width * 0.5, r1.Top + r1.Height * 0.7, r2.Left + r2.Width * 0.5, r2.Top + r2.Height * 0.3 Next End Sub