以下代码在我的函数开头使用。我只是定义一个包含数字作为变量的单元格,以便减少我的代码后面的输入量。我很困惑,因为我的变量类型没什么特别的,只是一个好的数字..
Sub PECcalc()
Dim pu238 As [Worksheets("PEC Conversion").Cells(4, 6).Value]
Dim pu241 As [Worksheets("PEC Conversion").Cells(5, 6).Value]
Dim am241 As [Worksheets("PEC Conversion").Cells(6, 6).Value]
Dim pu238PEC As [Worksheets("PEC Conversion").Cells(2, 2).Value]
Dim pu239PEC As [Worksheets("PEC Conversion").Cells(3, 2).Value]
Dim pu240PEC As [Worksheets("PEC Conversion").Cells(4, 2).Value]
Dim pu241PEC As [Worksheets("PEC Conversion").Cells(5, 2).Value]
Dim am241PEC As [Worksheets("PEC Conversion").Cells(6, 2).Value]
Dim np237PEC As [Worksheets("PEC Conversion").Cells(7, 2).Value]
Dim u328PEC As [Worksheets("PEC Conversion").Cells(8, 2).Value]
Dim u235PEC As [Worksheets("PEC Conversion").Cells(9, 2).Value]
答案 0 :(得分:1)
Sub PECcalc()
Dim pu238 As Double
pu238 = Worksheets("PEC Conversion").Cells(4, 6).Value
Dim pu241 As Double
pu241 = Worksheets("PEC Conversion").Cells(5, 6).Value
Dim am241 As Double
am241 = Worksheets("PEC Conversion").Cells(6, 6).Value
Dim pu238PEC As Double
pu238PEC = Worksheets("PEC Conversion").Cells(2, 2).Value
Dim pu239PEC As Double
pu239PEC = Worksheets("PEC Conversion").Cells(3, 2).Value
Dim pu240PEC As Double
pu240PEC = Worksheets("PEC Conversion").Cells(4, 2).Value
Dim pu241PEC As Double
pu241PEC = Worksheets("PEC Conversion").Cells(5, 2).Value
Dim am241PEC As Double
am241PEC = Worksheets("PEC Conversion").Cells(6, 2).Value
Dim np237PEC As Double
np237PEC = Worksheets("PEC Conversion").Cells(7, 2).Value
Dim u328PEC As Double
u328PEC = Worksheets("PEC Conversion").Cells(8, 2).Value
Dim u235PEC As Double
u235PEC = Worksheets("PEC Conversion").Cells(9, 2).Value
'...etc
或其他风格:
Sub PECcalc()
Dim pu238 As Double
Dim pu241 As Double
Dim am241 As Double
Dim pu238PEC As Double
Dim pu239PEC As Double
Dim pu240PEC As Double
Dim pu241PEC As Double
Dim am241PEC As Double
Dim np237PEC As Double
Dim u328PEC As Double
Dim u235PEC As Double
pu238 = Worksheets("PEC Conversion").Cells(4, 6).Value
pu241 = Worksheets("PEC Conversion").Cells(5, 6).Value
am241 = Worksheets("PEC Conversion").Cells(6, 6).Value
pu238PEC = Worksheets("PEC Conversion").Cells(2, 2).Value
pu239PEC = Worksheets("PEC Conversion").Cells(3, 2).Value
pu240PEC = Worksheets("PEC Conversion").Cells(4, 2).Value
pu241PEC = Worksheets("PEC Conversion").Cells(5, 2).Value
am241PEC = Worksheets("PEC Conversion").Cells(6, 2).Value
np237PEC = Worksheets("PEC Conversion").Cells(7, 2).Value
u328PEC = Worksheets("PEC Conversion").Cells(8, 2).Value
u235PEC = Worksheets("PEC Conversion").Cells(9, 2).Value
'...etc