|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
当我在A7:B1000之间输入坐标之后,点击计算 输入模型比尺之后,D7:F1000将会显示处相应的值。我现在遇到一个问题,就是当我点击计算之后,改变模型比尺,D7列会发生变化,但是E F列不会发生改变(图中框出来的地方),除非你在A7:B1000之间再加入新的坐标,它才会发生改变。以下是我的代码
Sub CAD到场地()
sp = Application.InputBox("请输入水平比尺", "输入提示", , , , , , 1)
If sp = 0 Then
MsgBox ("比尺要大于零")
Exit Sub
End If
For i = 7 To Sheets(1).Cells(60000, 1).End(3).Row
jidianX = Cells(2, 2) ' ═╮
jidianY = Cells(2, 4) ' ║
lingdianX = Cells(4, 2) ' ║
lingdianY = Cells(4, 4) ' ═ ╯
Cells(i, 4) = Sqr((Abs(Cells(i, 1) - jidianX) ^ 2) + (Abs(Cells(i, 2) - jidianY) ^ 2)) / (sp * 1)
Cosjiaodu = ((Cells(i, 1) - Cells(2, 2)) * (Cells(2, 4) - Cells(2, 2)) + (Cells(i, 2) - Cells(2, 4)) * (Cells(4, 4) - Cells(4, 2)) / ((Cells(4, 2) - Cells(2, 2)) ^ 2 + (Cells(4, 4) - Cells(2, 4)) ^ 2) ^ 0.5 / (Cells(i, 1) - Cells(2, 2)) ^ 2 + (Cells(i, 2) - Cells(2, 4)) ^ 2) ^ 0.5
fanzhengxian = Application.WorksheetFunction.Degrees(Application.WorksheetFunction.Atan2((Cells(i, 2) - Cells(2, 4)), (Cells(i, 1) - Cells(2, 2))) - Application.WorksheetFunction.Atan2((Cells(4, 4) - Cells(2, 4)), (Cells(4, 2) - Cells(2, 2))))
jueduizhi = Abs(fanzhengxian)
If Cells(i, 1) = "" Or Cells(i, 2) = "" Then
Cells(i, 5) = ""
Cells(i, 6) = ""
Cells(i, 4) = ""
ElseIf fanzhengxian >= 0 Then
Cells(i, 5) = Application.WorksheetFunction.Text((360 - jueduizhi) / 24, "[h]°m′sss″")
Cells(i, 6) = 360 - jueduizhi
Else
Cells(i, 5) = Application.WorksheetFunction.Text((jueduizhi) / 24, "[h]°m′sss″")
Cells(i, 6) = jueduizhi
End If
Next i
End Sub
|
|