|
こんなで善かったかな?
善く確かめて下さい
確か"."が入るか、入ら無いかとでは、
ミリ単位と受けるか?、ミクロン単位で受けるか?が違うのでしたよね?
後、"."の前の0は要りましたっけ? 0.2 → .2
Option Explicit
Public Sub Sample()
'◆Listのデータ列数(A列〜F列)
Const clngColumns As Long = 6
'表示書式
Const cstrForm As String = "0.###"
Dim i As Long
Dim lngRows As Long
Dim rngList As Range
Dim strResult As String
Dim vntData As Variant
Dim dblResult As Double
Dim dblPai As Double
Dim strProm As String
'πの値を取得
dblPai = Application.WorksheetFunction.Pi
'◆Listの先頭セル位置を基準とする(A列の列見出しのセル位置)
Set rngList = ActiveSheet.Cells(1, "A")
With rngList
'行数の取得
lngRows = .Offset(Rows.Count - .Row, 1).End(xlUp).Row - .Row
If lngRows <= 0 Then
strProm = "データが有りません"
GoTo Wayout
End If
End With
'画面更新を停止
Application.ScreenUpdating = False
With Application.WorksheetFunction
For i = 1 To lngRows
'A〜F列までの値を配列に取得
vntData = rngList.Offset(i).Resize(, clngColumns).Value
'出力用文字列を作成
strResult = "G3X" & Format(.Round(vntData(1, 5), 3), cstrForm) & "Z"
dblResult = vntData(1, 6) - vntData(1, 3) _
* Tan(vntData(1, 4) * dblPai / 180) _
* Tan((90 - vntData(1, 4)) _
* dblPai / 180) - vntData(1, 2)
strResult = strResult & Format(.Round(dblResult, 3), cstrForm)
strResult = strResult & "R" & Format(.Round(vntData(1, 2), 3), cstrForm)
'文字列を出力
rngList.Offset(i + 3, clngColumns + 1).Value = strResult
Next i
End With
strProm = "処理が完了しました"
Wayout:
'画面更新を再開
Application.ScreenUpdating = True
Set rngList = Nothing
MsgBox strProm, vbInformation
End Sub
|
|