Im trying to create a data form to upload details to spreadsheet. I have created the form in VBA but when I try and play it i get the error message "run time error 424 object not found." I cant seem to find the problem in the code and have stared at it for so long I feel a bit like an eskino staring at the snow. Any suggestions will be welcome below is the code
Private Sub cmdCancel_Click() Unload Me End Sub Private Sub cmdClearForm_Click() Call UserForm_Initialize End Sub Private Sub cmdOK_Click() ActiveWorkbook.Sheets("Sheet 1").Activate Range("A3").Select ActiveCell.Value = cboCSR.Value ActiveCell.Offset(0, 1) = txtDate.Value ActiveCell.Offset(0, 2) = txtCaseNo.Value ActiveCell.Offset(0, 3) = txtCallbackDate.Value ActiveCell.Offset(0, 4) = txtTimeWindow.Value ActiveCell.Offset(0, 5) = cboAssign.Value ActiveCell.Offset(0, 6) = txtContactNo.Value ActiveCell.Offset(0, 7) = txtOrangeNo.Value End If End If Range("A3").Select End Sub Private Sub UserForm_Initialize() txtName.Value = "" txtDate.Value = "" With cboCSR .AddItem "Andy" .AddItem "Ian" .AddItem "Vici" .AddItem "Marcia" .AddItem "Nina" .AddItem "Emma" .AddItem "Wendy" .AddItem "Dave" .AddItem "George" .AddItem "Nick" .AddItem "Alina" .AddItem "Janey" .AddItem "Debbie" .AddItem "Sharon" .AddItem "Mark M" .AddItem "Mark B" .AddItem "Kayley" .AddItem "Andrea" .AddItem "Gill" .AddItem "Suzanne" .AddItem "Linda" .AddItem "Sheena" .AddItem "Alison" .AddItem "Katie" .AddItem "Paula" .AddItem "Joe" .AddItem "Gary" .AddItem "Annie" End With cboCSR.Value = "" txtCaseNo.Value = "" txtCallbackDate.Value = "" txtTimeWindow.Value = "" With cboAssign .AddItem "Andy" .AddItem "Ian" .AddItem "Vici" .AddItem "Marcia" .AddItem "Nina" .AddItem "Emma" .AddItem "Wendy" .AddItem "Dave" .AddItem "George" .AddItem "Nick" .AddItem "Alina" .AddItem "Janey" .AddItem "Debbie" .AddItem "Sharon" .AddItem "Mark M" .AddItem "Mark B" .AddItem "Kayley" .AddItem "Andrea" .AddItem "Gill" .AddItem "Suzanne" .AddItem "Linda" .AddItem "Sheena" .AddItem "Alison" .AddItem "Katie" .AddItem "Paula" .AddItem "Joe" .AddItem "Gary" .AddItem "Annie" End With cboAssign.Value = "" txtContactNo.Value = "" txtOrangeNo.Value = "" End Sub
Last edited by GingerJah; 05-12-2010 at 06:31 AM.
Welcome to the Forum
Add Code tags before the moderators get you!!...
Forum Rules
3. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # button at the top of the post window. If you are editing an existing post, press Go Advanced to see the # button
Maybe it is the sheet name
Private Sub cmdCancel_Click() Unload Me End Sub Private Sub cmdClearForm_Click() Call UserForm_Initialize End Sub Private Sub cmdOK_Click() ActiveWorkbook.Sheets("Sheet1").Activate With .Range("A3") .Value = cboCSR.Value .Offset(0, 1) = txtDate.Value .Offset(0, 2) = txtCaseNo.Value .Offset(0, 3) = txtCallbackDate.Value .Offset(0, 4) = txtTimeWindow.Value .Offset(0, 5) = cboAssign.Value .Offset(0, 6) = txtContactNo.Value .Offset(0, 7) = txtOrangeNo.Value End With Range("A3").Select End Sub Private Sub UserForm_Initialize() txtName.Value = "" txtDate.Value = "" With cboCSR .AddItem "Andy" .AddItem "Ian" .AddItem "Vici" .AddItem "Marcia" .AddItem "Nina" .AddItem "Emma" .AddItem "Wendy" .AddItem "Dave" .AddItem "George" .AddItem "Nick" .AddItem "Alina" .AddItem "Janey" .AddItem "Debbie" .AddItem "Sharon" .AddItem "Mark M" .AddItem "Mark B" .AddItem "Kayley" .AddItem "Andrea" .AddItem "Gill" .AddItem "Suzanne" .AddItem "Linda" .AddItem "Sheena" .AddItem "Alison" .AddItem "Katie" .AddItem "Paula" .AddItem "Joe" .AddItem "Gary" .AddItem "Annie" End With cboCSR.Value = "" txtCaseNo.Value = "" txtCallbackDate.Value = "" txtTimeWindow.Value = "" With cboAssign .AddItem "Andy" .AddItem "Ian" .AddItem "Vici" .AddItem "Marcia" .AddItem "Nina" .AddItem "Emma" .AddItem "Wendy" .AddItem "Dave" .AddItem "George" .AddItem "Nick" .AddItem "Alina" .AddItem "Janey" .AddItem "Debbie" .AddItem "Sharon" .AddItem "Mark M" .AddItem "Mark B" .AddItem "Kayley" .AddItem "Andrea" .AddItem "Gill" .AddItem "Suzanne" .AddItem "Linda" .AddItem "Sheena" .AddItem "Alison" .AddItem "Katie" .AddItem "Paula" .AddItem "Joe" .AddItem "Gary" .AddItem "Annie" End With cboAssign.Value = "" txtContactNo.Value = "" txtOrangeNo.Value = "" End Sub
And maybe indicate what line is giving you the error message.
Dom
"May the fleas of a thousand camels infest the crotch of the person who screws up your day and may their arms be too short to scratch..."
Use code tags when posting your VBA code: [code] Your code here [/code]
Remember, saying thanks only takes a second or two. Click the little star to give some Rep if you think an answer deserves it.
It is not displaying which line is generatingthe error message
I suspect one of your control names is wrong. When you get the error, press Debug then press f8 repeatedly to step through the code line by line and see where the actual error is.
Try this
Private Sub cmdClearForm_Click() UserForm1.Show End Sub
You would also save a lot of grief if you were to put your Combo List on a lookup sheet and call the items from there. Either in the properties pane, or via code.
Also in Private Sub cmdOK_Click()
You have two "End If"s without an If statement, try this
Private Sub cmdOK_Click() With Sheets("Sheet 1").Range("A3") .Value = cboCSR.Value .Offset(0, 1) = txtDate.Value .Offset(0, 2) = txtCaseNo.Value .Offset(0, 3) = txtCallbackDate.Value .Offset(0, 4) = txtTimeWindow.Value .Offset(0, 5) = cboAssign.Value .Offset(0, 6) = txtContactNo.Value .Offset(0, 7) = txtOrangeNo.Value End With End Sub
Cheers
Thanks for that the line showing as the error are
the first two after the button commands, they are
Private Sub UserForm_Initialize()
txtName.Value = ""
I'd double check the control name then. If you delete theline and typetxtName.Value = ""you should get a list of the properties (including control names) that start with 't' so check if yours is listed.Me.t
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks