快速问题。我正在尝试创建一个程序,该程序查找大于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