VBA "Run-time error '424': Object required

Larsid

New Member
Joined
Dec 15, 2009
Messages
2
This my first attempt writing code in Excel. I am stupmed on why when i press run sub while under forms the following code works but when i load it into Modules and run it I get "run-time error 424 object required"?
I get the error on the bold text.

Sub PartListForm()
UserForm.Show
End Sub
Private Sub cmdOK_Click()
ActiveWorkbook.Sheets("Part_List").Activate
Range("a3").Select

Do

If IsEmpty(ActiveCell) = False Then
ActiveCell.Offset(1, 0).Select
End If
Loop Until IsEmpty(ActiveCell) = True
ActiveCell.Value = txtPartNumber.Value
ActiveCell.Offset(0, 1) = txtCustomer.Value
ActiveCell.Offset(0, 2) = txtCustomerItemNumber.Value
ActiveCell.Offset(0, 3) = txtothercustitem.Value
ActiveCell.Offset(0, 4) = txtFilmType.Value
ActiveCell.Offset(0, 5) = txtFilmSize.Value
ActiveCell.Offset(0, 6) = txtFinishedRollSize.Value
ActiveCell.Offset(0, 7) = txtSleeveSize.Value
ActiveCell.Offset(0, 8) = txtMachineType.Value
Range("A3").Select
End Sub
Private Sub PartListForm_Initialize()
txtPartNumber.Value = ""
txtCustomer.Value = ""
txtCustomerItemNumber.Value = ""
txtothercustitem.Value = ""
txtFilmType.Value = ""
txtFilmSize.Value = ""
txtFinishedRollSize.Value = ""
txtSleeveSize.Value = ""
txtMachineType.Value = ""
txtPartNumber.SetFocus
End Sub
Private Sub cmdCancel_Click()
Unload Me
End Sub
Private Sub cmdReset_Click()
Call UserForm_Initialize
End Sub

Thanks
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
The code does not "know" where to look outside the form - so you need to be explicit, something like :-

Userform1.txtPartNumber.Value = ""

(it is not a good idea to use "reserved words" as variable names.
ie. words that Excel uses already. In this case 'Userform' is an object type. We can often get away with it, but as a project grows the code can start giving errors.)
 
Upvote 0

Forum statistics

Threads
1,213,492
Messages
6,113,967
Members
448,537
Latest member
Et_Cetera

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