코드를 실행할 때 워크 시트에 결과가 나타나지 않는 이유는 무엇입니까? 내 코드에 문제가 있습니까? 누군가 확인해 줄 수 있습니까? 이건 내 코드입니다 :VBA가 워크 시트에 아무런 결과도 표시하지 않습니다.
Private Sub CommandButton1_Click()
Dim Globalstrahlung, Koll_ein_o, Koll_aus_o, Aussentemp, MIDsolar As Double
Dim a1, a2, b1, b2, c1, c2, d1, d2, e1, e2, f1, f2, g1, g2, x As Double
Dim cpTyf, RohTyf As Double
Dim Psolar, Puse_coll, Coll_eff As Double
Dim iCntr As Long
For iCntr = 3 To 8640
Globalstrahlung = Range("B" & iCntr)
Koll_ein_o = Range("C" & iCntr)
Koll_aus_o = Range("D" & iCntr)
Aussentemp = Range("E" & iCntr)
MIDsolar = Range("F" & iCntr)
x = (Koll_ein_o + Koll_aus_o)/2
x = Range("AW" & iCntr)
'Function cp(t) Tyfocor 35%
a1 = 3.5199
b1 = 0.0042
c1 = -0.00002
d1 = 0.0000009
e1 = -0.00000002
f1 = 0.0000000001
g1 = -0.0000000000005
cpTyf = a1 + (b1 * x) + (c1 * (x^2)) + (d1 * (x^3)) + (e1 * (x^4)) + (f1 * (x^5)) + (g1 * (x^6))
cpTyf = Range("AX" & iCntr)
'Function Roh(t) Tyfocor 35%
a2 = 1045
b2 = -0.453
c2 = 0.0051
d2 = 0.00007
e2 = -0.0000007
f2 = 0.000000004
g2 = -0.00000000001
RohTyf = a2 + (b2 * x) + (c2 * (x^2)) + (d2 * (x^3)) + (e2 * (x^4)) + (f2 * (x^5)) + (g2 * (x^6))
RohTyf = Range("AY" & iCntr)
'Collector capacity
Puse_coll = (MIDsolar/3600) * cpTyf * RohTyf * (Koll_aus_o - Koll_ein_o)
Puse_coll = Range("AZ" & iCntr)
'Solar capacity
Psolar = Globalstrahlung * 18.12
Psolar = Range("BA" & iCntr)
'Collector efficiency
If Globalstrahlung = 0 Then
Coll_eff = 0
ElseIf Globalstrahlung <> 0 Then
Coll_eff = (Puse_coll)/(Psolar)
End If
Coll_eff = Range("BB" & iCntr)
Range("BB" & iCntr).HorizontalAlignment = xlCenter
Range("BB" & iCntr).NumberFormat = "0.00"
Next
End Sub
.Value를 넣은 후에 작동합니다. 고맙습니다. 당신은 이렇게 말하면 : Dim a1, a2, b1, b2, c1, c2, d1, d2, e1, e2, f1, f2, g1, g2, x Double.Only x는 Double로 선언됩니다. a1과 다른 사람들이 Double을 원한다면, 다음과 같이해야합니다 : Dim a1을 Double, (다음 문장) Dim a2를 Double으로 사용 – Ary
예, 별도의 문장을 사용할 필요는 없습니다. : 'Dim a As Double, b as Double, c As Double '등 ... 각 변수 이름 다음에 선언이 있고 행 시작 부분에'Dim' 키워드를 사용하는 한. –
Variant로 불필요한 값을 선언하면 시간과 메모리가 많이 소모 될 수 있다는 것을 알고 있습니다. 팁 주셔서 감사합니다. – Ary