Need help getting rid of the "Need Object" error when running my code

j2mbs

New Member
Joined
Jul 15, 2011
Messages
13
Hello All

I am having trouble understanding why I am getting the "Object Needed" error code when running my code below.

I have created a userform (frmActualCost) for users to enter a job number into a text box (txtJN), and select a fiscal period from a combo box (cboGLP) before clicking "OK" button (cmdOK). When I go to test my macro it is getting hung up at 'SET strJN = Me.txtJN.Text code line. I tried declaring frmActualCost as an object, and searched for other possible solutions but I am unable to solve this.

Can you please take a look and let me know where I went wrong? I appreciate any help.

Thank you

Code:
Private Sub cmdOK_Click()
On Error GoTo Handler
    Dim shtDest, shtSource As Worksheet
    Dim wbSource As Workbook
    Dim strJN As String
    Dim strGLP As String
    Dim strURL As String
    Dim tblActualCost As ListObject
    Dim tblRows As Long
    Dim Rng As Range
    Dim LastRowSource, LastRowDest, LastRow As Long
    Dim objActualCost As Object
    
    Application.ScreenUpdating = False
    Application.DisplayAlerts = False
    Set shtDest = ThisWorkbook.Sheets("Actual Cost")
    Set tblActualCost = shtDest.ListObjects("ActualCost_Table")
    Set objActualCost = frmActualCost
    Set strJN = Me.txtJN.Text
    Set strGLP = Me.cboGLP.Value
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
Remove the word Set.
You only Set objects, but you have declared strJN as String & therefore does not need to be Set.
 
Upvote 0
Glad to help & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,329
Members
452,635
Latest member
laura12345

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