【发布时间】:2017-01-20 20:48:02
【问题描述】:
如果这是在其他地方发布的,我深表歉意,但我在理解 sub 调用用户表单和用户表单控件之间的关系时遇到了问题。我有一个子程序,可以将数据从另一个工作表填充到工作表中。需要填写的单元格之一是对项目数量变化的解释。我生成了一个带有选项按钮的用户表单,用户可以从中选择适当的“原因”。单击确定按钮后,它将把选定的原因放在工作表的单元格中。
在 sub 中,我使用范围内的 For Each 单元格来为高于特定条件的每个值填充行中的数据,并且它应该显示满足条件的每个单元格的表单。我可以将我用作行引用的单元格传递到用户表单中,以便它可以使用该单元格作为偏移量来输入所选的“原因”然后卸载表单吗?
Private Sub okbutton1_Click(bc As Range) 'bc should be the range from the sub calling this form
Select Case True
Case OptionButton1
If bc.Offset(0, 3).Value = "A" Then
Set bc.Offset(0, 6).Value = "Actual amount required is more than plan quantity."
Else
Set bc.Offset(0, 6).Value = "Actual amount required is less than plan quantity."
End If
Case OptionButton2
Set bc.Offset(0, 6).Value = "This items was not constructed/used/required."
Case OptionButton3
Set bc.Offset(0, 6).Value = "Only a portion of the contingency was required for items not in original plan."
Case OptionButton4
Set bc.Offset(0, 6).Value = "Deficiency levied against Contractor per IDOT Section 105.03."
Case OptionButton5
Set bc.Offset(0, 6).Value = "Damages levied against Contractor per IDOT Section 108.09."
Case OptionButton6
Set bc.Offset(0, 6).Value = InputBox("Please enter your reasoning below.", "Other")
End Select
Unload AuthReason2
End Sub
那么这是我用来填充工作表的子组件的一部分。
Line5: 'Populates the BLR13210A from the data entered on the BLR13210
Application.ScreenUpdating = False
Dim bws As Worksheet
Set bws = Worksheets("BLR 13210A")
Dim Arange As Range
Set Arange = aws.Range("AZ34:AZ198")
Dim Bcell As Range ' First cell in AttachA form
Set Bcell = bws.Range("B11")
For Each ACell In Arange
If ACell.Value > 1999.99 Then
Bcell.Value = ACell.Offset(0, -47).Value
Bcell.Offset(0, 1).Value = ACell.Value
Bcell.Offset(0, 2).Value = ACell.Offset(0, -37).Value
Bcell.Offset(0, 3).Value = ACell.Offset(0, -22).Value
AuthReason2(Bcell).Show
End If
Bcell = Bcell.Offset(1, 0)
Application.ScreenUpdating = True
提前感谢您的帮助。
【问题讨论】: