初歩的な事ですが、For~Next、If~If Endの組み合わせがよく分かりません。現在エクセルで下記計算表 s3部分の追記作成をしてるのですがエラーが連発します。どなたか何卒ご教授ねがいます。
Sub 計算()
For s1 = 3 To 6
If Cells(11, s1) = 0 Or Cells(11, s1) = "" Then
For s2 = 12 To 23
Cells(s2, s1) = ""
Next s2
Else
For s3 = 17 To 20
mt = 9550 * Range("c4") / Range("c5") * 1000
Range("q3").Value = mt
m = Range("c6") * Cells(13, s1)
Cells(4, s3).Value = m
mme = 0.5 * (m + (m ^ 2 + mt ^ 2) ^ 0.5)
Cells(5, s3).Value = mme
z = 3.14 * Cells(12, s1) ^ 3 / 32
Cells(6, s3).Value = z
Cells(18, s1) = mme / z
mte = ((Range("g3") * m + Range("c7") * Cells(12, s1) / 8) ^ 2 + (Range("g4") * mt) ^ 2) ^ 0.5
Cells(7, s3).Value = mte
zp = 3.14 * Cells(12, s1) ^ 3 / 16
Cells(8, s3).Value = zp
Cells(19, s1) = mte / zp
z1 = 1 - Range("j10") / Range("j7") * (0.522 * 2.718 ^ (-5.33 / Cells(12, s1)) - 0.306)
Cells(9, s3).Value = z1
z2 = 0.75 - 0.1 * (70 * 9.8 - Range("j7")) / (50 * 9.8)
Range("q11").Value = z2
e = 1 - 0.2 * Cells(16, s1) / Cells(12, s1) - 1.1 * Cells(15, s1) / Cells(12, s1)
Cells(10, s3).Value = e
(途中省略)
t1 = 0.63 + 0.0227 * Range("j7") / 9.8
t2 = 1 - 2.718 ^ (-0.1 * Cells(12, s1))
If Cells(14, s1) = 0 Or Cells(14, s1) = "" Then
t3 = 1
Else
t3 = 1 - 2.718 ^ (-0.025 * Cells(12, s1) / Cells(14, s1))
End If
t4 = 1 - 2.718 ^ (-3.4 * (1 - Cells(12, s1) / Cells(11, s1)))
Cells(21, s1) = z1 * z2 / (1 + t1 * t2 * t3 * t4) * e * Range("j9")
Cells(22, s1) = Cells(20, s1) / Cells(18, s1)
Cells(23, s1) = Cells(21, s1) / Cells(19, s1)
Next s3, s1
End If
End Sub
お礼
n-jun 様、回答をありがとうございます。 お陰でなんとか解決しました。