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
 

Some videos you may like

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
46,530
Office Version
  1. 365
Platform
  1. Windows
Remove the word Set.
You only Set objects, but you have declared strJN as String & therefore does not need to be Set.
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
46,530
Office Version
  1. 365
Platform
  1. Windows
Glad to help & thanks for the feedback
 

Watch MrExcel Video

Forum statistics

Threads
1,109,336
Messages
5,528,104
Members
409,802
Latest member
joeino

This Week's Hot Topics

  • Change military grades into rank
    Afternoon all Need help with formula that will change military rank (i.e. 1, 2, 3 into Amn, A1C, SrA). Running IF formula that does not work...
  • VBA COUNTIF SOLUTION
    Hi The following are the errors spread across the several columns from E to Q ie. 13 columns across several sheets with more than 500 rows per...
  • INSERT ROW WITH SPECIFIS TEXT IN A COLUMN
    Hi All! How can identify that that the row to be inserted has to be inserted before 1st row with specific text in column F. If I record the...
  • Auto-Create a monthly Sign in sheet for preschool students
    The image below is what each page looks like. Above is space for the "Child Name" "Month" "Class" School days are obviously Monday-Friday but...
  • VBA vlookup multiple results
    Hi folks, Hopefully someone out there can help. I have a list to vlookup which works (ish). the lookup only picks up the first instance of the...
  • Extract values for earliest/latest times
    I am trying to put together a formula to get the earliest start time, the latest end time from column A for each person in Column B-F without the...
Top