让我先说一下我的问题,说我之前没有任何编程语言的经验。但是,我想设计一个允许用户在Excel工作表中的特定区域输入信息的UserForm。
我正在使用9个组合框和1个文本框。我验证了代码中正确引用了所有组合框,但在尝试使“OK”按钮工作时,我不断收到编译错误。
Private Sub cmdCancel_Click()
Unload Me
End Sub
Private Sub cmdOK_Click()
Dim RowCount As Long
Dim ctl As Control
RowCount = Worksheets("February Renewals").Range("S5").CurrentRegion.Rows.Count
With Worksheets("February Renewals").Range("S5")
Offset(RowCount, 0).Value = Me.ComboBoxStatus.Value
Offset(RowCount, 1).Value = Me.ComboBoxRemarketed.Value
Offset(RowCount, 2).Value = Me.ComboBoxCarrier1.Value
Offset(RowCount, 3).Value = Me.ComboBoxCarrier2.Value
Offset(RowCount, 4).Value = Me.ComboBoxCarrier3.Value
Offset(RowCount, 5).Value = Me.ComboBoxOptional1.Value
Offset(RowCount, 6).Value = Me.ComboBoxOptional2.Value
Offset(RowCount, 7).Value = Me.ComboBoxOptional3.Value
Offset(RowCount, 8).Value = Me.ComboBoxLost.Value
Offset(RowCount, 9).Value = Me.txtAdditionalNotes.Value
End Sub
为什么我收到此消息以及如何解决此问题?
答案 0 :(得分:2)
您在OFFSET之前缺少DOT。试试这个
With Worksheets("February Renewals").Range("S5")
.Offset(RowCount, 0).Value = Me.ComboBoxStatus.Value
.Offset(RowCount, 1).Value = Me.ComboBoxRemarketed.Value
.Offset(RowCount, 2).Value = Me.ComboBoxCarrier1.Value
.Offset(RowCount, 3).Value = Me.ComboBoxCarrier2.Value
.Offset(RowCount, 4).Value = Me.ComboBoxCarrier3.Value
.Offset(RowCount, 5).Value = Me.ComboBoxOptional1.Value
.Offset(RowCount, 6).Value = Me.ComboBoxOptional2.Value
.Offset(RowCount, 7).Value = Me.ComboBoxOptional3.Value
.Offset(RowCount, 8).Value = Me.ComboBoxLost.Value
.Offset(RowCount, 9).Value = Me.txtAdditionalNotes.Value
End Sub