• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

object required

Reggieneo

Member
Hi All,
I can't get thru this error "object required"

Code:
Sub CopyRow2()


Dim lastrowSrc As Variant
Dim lastrowDest As Variant
Dim wb, wb1 As Workbook

    wb = "C:\Dropbox\Folder\gsreport 2017 Final 3 - 012018.xlsm"
  
lastrowSrc = wb.Sheets("Sheet1").Range("A" & Rows.Count).End(xlUp).EntireRow

   lastrowDest = ThisWorkbook.Sheets("Sheet1").Range("A" & Rows.Count).End(xlUp).EntireRow

  lastrowDest = ExecuteExcel4Macro(lastrowSrc)



End Sub
I have set it, declare but still not able to pass through it.

Kindly assist,
reggienoe

MOD EDIT: FIXED CODE TAGS LOCATION.
 
Last edited by a moderator:
If AlanSidman's suggestion doesn't work, try:
if the workbook is already open:
Set wb =Workbooks("gsreport 2017 Final 3 - 012018.xlsm")
and if the workbook isn't open:
Set wb =Workbooks.open("C:\Dropbox\Folder\gsreport 2017 Final 3 - 012018.xlsm")
(completely untested!)
 
Not sure what you are trying to do... but there are multiple issues in your code.

1. Argument for ExecuteExcel4Macro() should be string.

You are passing variant() to Method that requires "A Microsoft Excel 4.0 macro language function without the equal sign." (i.e. string).
https://msdn.microsoft.com/en-us/vba/excel-vba/articles/application-executeexcel4macro-method-excel

You can check variable type held by using...
Code:
Debug.Print TypeName(lastrowSrc)

2. While your reference should return range object, you have not Set it. So it remains variant(). Though I have no clue what you actually wanted.
Ex: To return range object
Code:
Set lastrowSrc = Sheets("Sheet1").Range("A" & Rows.Count).End(xlUp).EntireRow

3. As others have mentioned. You have declared workbook object variable, but have not set it.
 
Back
Top