Variable not defined error/ Command Button

lori_ann

New Member
Joined
Aug 2, 2019
Messages
5
Happy Friday,
I'm very familiar with excel, but not so much with VBA. I'm creating a form with drop downs and one "enter" button at the bottom. When I go to test I get a Variable not defined error with PrivateSub CommandButton1_Click() highlited in yellow along with the (x1Down). Help Please:)


End Function
Private Sub CommandButton1_Click()

Application.ScreenUpdating = False
Dim iRow As Long

iRow = Sheets("Data").Range("A2:A1048576").End(x1Down).Row + 1


If ValidateForm = True Then

With ThisWorkbook.Sheets("Data")
.Range("A" & iRow).Value = iRow - 1
.Range("B" & iRow).Value = monthinspected.Text
.Range("C" & iRow).Value = Inspector.Text
.Range("D" & iRow).Value = inspecitontype.Text

End With
Call Reset
Else
Application.ScreenUpdating = True
Exit Sub
End If
Application.ScreenUpdaitng = True


End Sub
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
Hi & welcome to MrExcel.
It should be xldown (lower case L), not x1down (numeral one)
 
Upvote 0
Should it also be up not down?

Code:
iRow = Sheets("Data").Cell(Sheets("Data").Rows.Count, "A").End(xlUp).Row + 1
 
Last edited:
Upvote 0
Thank you. I'm apologizing in advance. I believe that worked as that error message is gone. Now I have a pop up after I choose the inspection type and then press the button and a message box Qualification....Please select the inspection type from drop down. It highlites that box in red and populates this long number in the box. I'm not sure where the number comes from as it's a drop down list of text.

Here is the beginning code:
Option Explicit


Function ValidateForm() As Boolean

monthinspected.BackColor = vbWhite
Inspector.BackColor = vbWhite
inspectiontype = vbWhite

ValidateForm = True

If monthinspected.Text <> "January" And monthinspected.Text <> "February" And monthinspected.Text <> "March" And monthinspected.Text <> "April" And monthinspected.Text <> "May" And monthinspected.Text <> "June" And monthinspected.Text <> "July" And monthinspected.Text <> "August" And monthinspected.Text <> "September" And monthinspected.Text <> "October" And monthinspected.Text <> "November" And monthinspected.Text <> "December" Then
MsgBox "Please select the correct month from drop down.,", vbOKOnly + vbInformation, "Qualification"
monthinspected.BackColor = vbRed
monthinspected.Activate
ValidateForm = False

ElseIf Inspector.Text <> "Chuck" And Inspector.Text <> "Rob" And Inspector.Text <> "Other" Then
MsgBox "Please select the correct Inspector from drop down.,", vbOKOnly + vbInformation, "Qualification"
Inspector.BackColor = vbRed
Inspector.Activate
ValidateForm = False

ElseIf inspectiontype.Text <> "Footings" And inspectiontype.Text <> "Foundation" And inspectiontype.Text <> "Underground Plumbing" And inspectiontype.Text <> "Underground Heating" And inspectiontype.Text <> "Framing" And inspectiontype.Text <> "Rough Plumbing" And inspectiontype.Text <> "Rough Heating" And inspectiontype.Text <> "Rough Electric" And inspectiontype.Text <> "Roof" And inspectiontype.Text <> "Electrical Service" And inspectiontype.Text <> "Electrical Temporary" And inspectiontype.Text <> "Final" And inspectiontype.Text <> "Pre Construction Inspection" And inspectiontype.Text <> "Courtesy Inspection" And inspectiontype.Text <> "Unsafe" Then
MsgBox "Please select the inspection type from drop down.,", vbOKOnly + vbInformation, "Qualification"
inspectiontype.BackColor = vbRed
inspectiontype.Activate
ValidateForm = False
End If

End Function
 
Last edited by a moderator:
Upvote 0
As this is now a totally different question, you will need to start a new thread.
Thanks
 
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,223,228
Messages
6,170,871
Members
452,363
Latest member
merico17

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top