Hi, I'm new here and fairly new to VBA in Excel. I'm attempting to call a Sub in a worksheet's code from a userform and I'm getting an error of Object Requied(as run from the userform):
It errors out with the Sheet2.EntryForm_Closeout line, which is supposed to refer to this on Sheet2's code:
I've even gone so far as to remove argument requirement to the EntryForm_Closeout sub and (after reflecting this change on the form's code) attempt to rerun, but it still says object required. I've tried calling the sheet as ThisWorkbook.Sheets("Backup Log"), etc, and they all still error out the same way. I've also tried using the Call statement.
Any help would be appreciated.
Code:
Private Sub CommandButton1_Click()
'Error check our entries and populate the Log with Form data
If Not IsNumeric(TextBox2.Value) Or TextBox2.Value < 1 Or TextBox2.Value > 12 Or InStr(TextBox2.Value, ".") Then
DateErrMsg ("Month")
ElseIf Not IsNumeric(TextBox3.Value) Or TextBox3.Value < 1 Or TextBox3.Value > 31 Or InStr(TextBox3.Value, ".") Then
DateErrMsg ("Day")
ElseIf Not IsNumeric(TextBox4.Value) Or Len(TextBox4.Value) <> 4 Or InStr(TextBox4.Value, ".") Then
DateErrMsg ("Year")
Else
Dim TargetRow As Integer
If InStr(Me.Caption, "New") Then
Sheet2.Rows("2:2").Insert Shift:=xlDown
TargetRow = 2
ElseIf InStr(Me.Caption, "Edit") Then
TargetRow = Selection.Row
End If
With Sheet2.Range("A" & TargetRow)
.ClearFormats
.NumberFormat = "m/d/yyyy"
.BorderAround
.Interior.ColorIndex = 35
.Value = TextBox2.Value & "/" & TextBox3.Value & "/" & TextBox4.Value
End With
Sheet2.EntryForm_Closeout (Sheet2.Range("A" & TargetRow & ":F" & TargetRow))
Unload Me
End If
End Sub
It errors out with the Sheet2.EntryForm_Closeout line, which is supposed to refer to this on Sheet2's code:
Code:
Sub EntryForm_Closeout(Target As Range)
ChangeActive = False
Worksheet_Change (Target)
End Sub
I've even gone so far as to remove argument requirement to the EntryForm_Closeout sub and (after reflecting this change on the form's code) attempt to rerun, but it still says object required. I've tried calling the sheet as ThisWorkbook.Sheets("Backup Log"), etc, and they all still error out the same way. I've also tried using the Call statement.
Any help would be appreciated.