- 帖子
- 132
- 主題
- 56
- 精華
- 0
- 積分
- 190
- 點名
- 0
- 作業系統
- Win10
- 軟體版本
- Office 365
- 閱讀權限
- 20
- 性別
- 男
- 註冊時間
- 2012-5-17
- 最後登錄
- 2025-4-8
|
我利用Userform做計算時需要選定要計算的欄位
故設定每一個section的起始欄位-"Start Row"及"End Row"
且在Critera存在時才可輸入起始欄位,當它為"N/A"時起使欄位則不可輸入
於是就寫了一長串的code
想問大家同樣的問題會怎麼寫可以比較簡化?
謝謝
'------------------------------------------
If TextBox3.Locked = True Then
CC = 1
Else
If TextBox5.Locked = True Then
CC = 2
Else
If TextBox7.Locked = True Then
CC = 3
Else
If TextBox9.Locked = True Then
CC = 4
Else
If TextBox11.Locked = True Then
CC = 5
End If
End If
End If
End If
End If
iC = 1
Do Until iC > CC
If iC = 1 Then
StartRow = Val(TextBox1.Text)
EndRow = Val(TextBox2.Text)
End If
If iC = 2 Then
StartRow = Val(TextBox3.Text)
EndRow = Val(TextBox4.Text)
End If
If iC = 3 Then
StartRow = Val(TextBox5.Text)
EndRow = Val(TextBox6.Text)
End If
If iC = 4 Then
StartRow = Val(TextBox7.Text)
EndRow = Val(TextBox8.Text)
End If
If iC = 5 Then
StartRow = Val(TextBox9.Text)
EndRow = Val(TextBox10.Text)
End If
If iC = 6 Then
StartRow = Val(TextBox11.Text)
EndRow = Val(TextBox12.Text)
End If
中間計算程式
iC = iC + 1
Loop
'---------------------------------- |
|