I'm sorry to be asking what I'm sure are beginner's questions, but I do appreciate all the help.
I am having trouble with a user form. It is linked to a spreadsheet titled "Employee_Info_Page". When I run the amend macro, I'm using this code
Private Sub cmdamend_Click()
Application.ScreenUpdating = False
If Rng Is Nothing Then GoTo skip
For Each c In Rng
If r = 0 Then c.Select
r = r - 1
Next c
skip:
Set c = ActiveCell
c.Value = Me.txtEmployeeName.Value ' write amendments to database
c.Offset(0, 1).Value = Me.txtDateofHire.Value
c.Offset(0, 2).Value = Me.txtDateInPosition.Value
c.Offset(0, 3).Value = Me.txtHomeNumber.Value
c.Offset(0, 4).Value = Me.TxtCellNumber.Value
c.Offset(0, 5).Value = Me.cmbEmployeePosition.Value
c.Offset(0, 6).Value = Me.cmbEmployeeDaysOff.Value
c.Offset(0, 7).Value = Me.cmbEmployeeSchedule.Value
c.Offset(0, 8).Value = Me.cmbFridayExtraDaysOff.Value
c.Offset(0, 9).Value = Me.cmbSaturdayExtraDaysOff.Value
c.Offset(0, 10).Value = Me.cmbSundayExtraDaysOff.Value
c.Offset(0, 11).Value = Me.cmbMondayExtraDaysOff.Value
c.Offset(0, 12).Value = Me.cmbTuesdayExtraDaysOff.Value
c.Offset(0, 13).Value = Me.cmbWednesdayExtraDaysOff.Value
c.Offset(0, 14).Value = Me.cmbThursdayExtraDaysOff.Value
'restore Form
With Me
.cmdamend.Enabled = False
.cmddelete.Enabled = False
.cmdadd.Enabled = True
.txtEmployeeName.Value = vbNullString
.txtDateofHire.Value = vbNullString
.txtHomeNumber.Value = vbNullString
.TxtCellNumber.Value = vbNullString
.cmbEmployeePosition.Value = vbNullString
.cmbEmployeeDaysOff.Value = vbNullString
.cmbEmployeeSchedule.Value = vbNullString
.cmbFridayExtraDaysOff.Value = vbNullString
.cmbSaturdayExtraDaysOff.Value = vbNullString
.cmbSundayExtraDaysOff.Value = vbNullString
.cmbMondayExtraDaysOff.Value = vbNullString
.cmbTuesdayExtraDaysOff.Value = vbNullString
.cmbWednesdayExtraDaysOff.Value = vbNullString
.cmbThursdayExtraDaysOff.Value = vbNullString
.Height = frmHt
End With
If Worksheets("Employee_Info_page").AutoFilterMode Then Worksheets("employee_info_page").ShowAllData
Application.ScreenUpdating = True
End Sub
The problem is early on at "If Rng Is Nothing Then GoTo skip." When it gets here, it says "Object expected," and I have no idea what to put in there.
Any help you can give on this is appreciated, and of course if you see any other obvious problems in their, I'd love it if you could point them out.
Thanks!
Bookmarks