Run-time error code when initiating userform

rizzo93

Active Member
Joined
Jan 22, 2015
Messages
303
Office Version
  1. 365
I'm trying to retrieve a cell's value to display in a userform text field.



Code:
Private Sub UserForm_Initialize()
    Call GetData
End Sub


Private Sub GetData()

    Dim r As Long
    
    r = Cells(ActiveCell.Row, 78).Value
    PMField.Text = Worksheets("GhostData").Cells(r, 132).Value
    
End Sub


When I run the code above, I get "Run-time error: '424' Object required"


What does that mean and how do I fix it, please?
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
Is all that code in the Userform Module?
 
Upvote 0
Doh! I forgot I had this has a macro before to test things out.


But now that it is in the userform, I'm getting this error message:


"Application-defined or object-defined error"
 
Upvote 0
Could you post you code as it is now & indicate which line of code is causing the error
 
Upvote 0
Code:
Sub PDCloseButton_Click()
    Unload Me
End Sub
Private Sub UserForm_Initialize()
    Call GetData
End Sub
Private Sub GetData()
    Dim r As Long
    
    r = Cells(ActiveCell.Row, 78).Value
    PMField.Text = Worksheets("GhostData").Cells(r, 132)
    
End Sub

I appreciate your help, Fluff.
 
Upvote 0
Do you have a control called PMField on the userform?
 
Upvote 0
Yes, I do. It's one of many fields on the form that I wish to populate. I'm just proceeding slowly to make sure I've got the code right.
 
Upvote 0
If you type
Code:
Me.P
in the code do you get a drop down showing PMField as an option?
 
Upvote 0

Forum statistics

Threads
1,223,908
Messages
6,175,306
Members
452,633
Latest member
DougMo

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