简体   繁体   中英

Why am I getting a compile error?

Let me preface my question by saying that I have no prior experience in any programming language. However, I am wanting to design a UserForm that allows users to enter information into specific areas in an Excel worksheet.

I am using 9 combo boxes and 1 text box. I verified that all of the combo boxes are correctly referenced in the code but I am continually getting a compile error when trying to make my "OK" button work.

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

Why am I getting this message and what can I do to resolve it?

You are missing a DOT before OFFSET. Try this

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM