Exce; - Urgent - Run-Time Error 424 Object (VBA)

A

ajw150

Hi,

Please can someone help me (and a few others by the looks of it) wit
an error I keep receiving. I have followed all the instructions in th
Course booking Example for creating a user form, but when it comes t
assigning the macro, it doesnt work. I then get the Run-time Error
424, Object undefined?

Please could someone tell me what I am doing wrong.

Thanks

Andre

Attachment filename: testa.xls
Download attachment: http://www.excelforum.com/attachment.php?postid=54132
 
M

mudraker

ajw150

Check your form name


Sub OpenStartdata()

frmStartdata.Show ' invalid form name

End Sub


should be

Sub OpenStartdata()

Startdata.Show ' valid form name

End Su
 
A

ajw150

Hi,

Just one last point.

I have found that, once the data has been entered into the userform an
the OK button is pressed, the user is automatically taken to the shee
where the new data has been added. I would like the user to return t
the sheet where they originated from, i.e macro location, how would
do this?

Really appreciate all your help.

Thanks

Andre
 
M

mudraker

ajw150

Using your code You would need to get the name of the active shee
before you activate sheet1 then activate that sheet after pastinging i
your data.

or you can replace your
Private Sub cmdOK_Click()

code with my version which puts your data on sheet1 without activatin
sheet1 which should solve your problem




Private Sub cmdOK_Click()

Dim wS As Worksheet
Dim lRow As Long

Set wS = ActiveWorkbook.Sheets("Sheet1")
l = Range("A" & Rows.Count).End(xlUp).Row + 1
wS.Cells(lRow, "a") = txtLMName.Value
wS.Cells(lRow, "b") = txtPName.Value
wS.Cells(lRow, "c") = txtAddress.Value
wS.Cells(lRow, "d") = txtAdd.Value
wS.Cells(lRow, "e") = txtemail.Value
wS.Cells(lRow, "f") = txtLMemail.Value
End Su
 
Top