快速問題。我正在嘗試創建一個程序,該程序查找大於I8中坦克的最大音量值的第一個實例。我想比較I13:I80中Vol列的體積與I8中的最大體積。然後,我希望excel將列B13:B80中的相應帶子作爲消息框輸出。因此,在這種情況下,會輸出一個消息框,指出「牆的高度爲16英寸」。由於B20是與大於最大值的第一個卷相對應的錶帶的值。Excel查找大於參考值的第一個實例
Public Sub dimensionInput()
Dim wallWidth As Double 'Get Wall Width Input
wallWidth = Application.InputBox("Input Desired Secondary Containment Wall Width in Inches", "Wall Width", 1)
If wallWidth = False Then
Call zeroFill
Exit Sub
Else
Application.Worksheets("Sheet1").Range("D3").Value = wallWidth
End If
Dim wallLen As Variant 'Get Wall Length Input
wallLen = Application.InputBox("Input Desired Secondary Containment Wall Width in Inches", "Wall Width", 1)
If wallLen = False Then
Call zeroFill
Exit Sub
Else
Application.Worksheets("Sheet1").Range("E3").Value = wallLen
End If
Dim arrayDia() As String
Dim diameter As Variant 'Get Diameter Input
diameter = Application.InputBox("Input Tank(s) Diameter Seperated by a Comma and Space e.g. N1, N2, N3, ...", "Diameter", 1)
arrayDia() = Split(diameter, ",")
For i = LBound(arrayDia) To UBound(arrayDia)
Cells(6, i + 3).Value = arrayDia(i)
Next i
Dim arrayLen() As String
Dim length As Variant 'Get Lenth Input
length = Application.InputBox("Input Desired Length Seperated by a Comma and Space e.g. N1, N2, N3, ...", "Length", 1)
arrayLen() = Split(length, ",")
For i = LBound(arrayLen) To UBound(arrayLen)
Cells(7, i + 3).Value = arrayLen(i)
Next i
'Dim arrayOrient() As String
'Dim orient As Variant 'Get Orient Input
'orient = Application.InputBox("Input Desired Orient", "Orient", H)
'arrayOrient() = Split(orient, ",")
'For i = LBound(arrayOrient) To UBound(arrayOrient)
' Cells(9, i + 3).Value = arrayOrient(i)
'Next i
Dim arrayOffset() As String
Dim offset As Variant 'Get Offset Input
offset = Application.InputBox("Input Desired Offset Seperated by a Comma and Space e.g. N1, N2, N3, ...", "Offset", 0)
arrayOffset() = Split(offset, ",")
For i = LBound(arrayOffset) To UBound(arrayOffset)
Cells(10, i + 3).Value = arrayOffset(i)
Next i
End Sub
Public Sub zeroFill()
Application.Worksheets("Sheet1").Range("C6:H7").Value = "0"
'Application.Worksheets("Sheet1").Range("C9:H9").Value = "H"
Application.Worksheets("Sheet1").Range("C10:H10").Value = "0"
End Sub
好的,那樣做。 –
我想@Tom想說什麼,你到底做了什麼? SO的人會幫助你修復不起作用的代碼,但大多數人不會爲你寫實際的代碼 - 至少在沒有簽署合同的情況下。 – FreeMan
我已經添加了我用於該項目的代碼。我不想讓任何人知道我想爲我完成的想法。如果有的話,我真的很想知道如何去做。我不是一個好的程序員,對錯誤交流表示歉意。 – JuliusDariusBelosarius