Object required

dpaton05

Well-known Member
Joined
Aug 14, 2018
Messages
2,330
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
I am getting the object required error with this code:
Code:
Sub cmdCopy()
    Dim wsDst As Worksheet, wsSrc As Worksheet, tblrow As ListRow
    Dim Combo As String, sht As Worksheet, tbl As ListObject
    Dim lastrow As Long, DocYearName As String, Site As String, lr As Long
    Dim RowColor As Long, w As Window, r As Long
        Application.ScreenUpdating = False
    'assign values to variables
    Set tbl = ThisWorkbook.Worksheets("Costing_tool").ListObjects("tblCosting")
    Set sht = ThisWorkbook.Worksheets("Costing_tool")
    Set Site = ThisWorkbook.Worksheets("Start_here").Range("H9").Value
    For Each tblrow In tbl.ListRows
        If tblrow.Range.Cells(1, 1).Value = "" Or tblrow.Range.Cells(1, 5).Value = "" Or tblrow.Range.Cells(1, 6).Value = "" Then
            MsgBox "The Date, Service or Requesting Organisation has not been entered for every record in the table"
            Exit Sub
        End If

"Site =" is highlighted and gives me the object required error, what am I missing?

Site is a contains a site in one word.

Thanks
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.

Michael M

Well-known Member
Joined
Oct 27, 2005
Messages
20,339
Office Version
  1. 2016
  2. 2013
  3. 2007
Platform
  1. Windows
Remove the word "Set"

Code:
Site = Worksheets("Start_here").Range("H9").Value
 

JLGWhiz

Well-known Member
Joined
Feb 7, 2012
Messages
12,979
Office Version
  1. 2013
Platform
  1. Windows
Set is only used to initialize object variables like workbooks, sheets and ranges. It is not used for text and numerical values.
 

dpaton05

Well-known Member
Joined
Aug 14, 2018
Messages
2,330
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Thanks Michael, that is perfect :)
 

Watch MrExcel Video

Forum statistics

Threads
1,132,677
Messages
5,654,690
Members
418,147
Latest member
dorkas

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
Top