Hello,
Hoping I could get some help. I'm working on a project and keep getting an application defined or object defined error.
I'm trying to select a range from A3 to column K with a dynamic row variable depending on the last row with data in it and clear contents.
Then I need to select the same range from 2 different spreadsheets and copy and paste values to the sheet where the data was cleared.
After checking the name of the spreadsheets in the code a couple of times I can't seem to find any issue with the syntax.
I believe that the issue is somewhere on the way I'm selecting a range to copy, this is where I'm getting the error:
This is my full code:
Hoping I could get some help. I'm working on a project and keep getting an application defined or object defined error.
I'm trying to select a range from A3 to column K with a dynamic row variable depending on the last row with data in it and clear contents.
Then I need to select the same range from 2 different spreadsheets and copy and paste values to the sheet where the data was cleared.
After checking the name of the spreadsheets in the code a couple of times I can't seem to find any issue with the syntax.
I believe that the issue is somewhere on the way I'm selecting a range to copy, this is where I'm getting the error:
Code:
Sheets("Materiales Riego VC").Range(Cells(3, 1), Cells(nextrowRiegoMaster, 11)).Copy
This is my full code:
VBA Code:
'MASTER
Dim nextrowMaster As Integer
Dim nextrowRiegoMaster As Integer
Dim nextrowJardinesMaster As Integer
nextrowMaster = WorksheetFunction.CountA(Sheets("Materiales Master").Range("D:D"))
Sheets("Materiales Master").Range(Cells(3, 1), Cells(nextrowMaster, 11)).ClearContents
nextrowRiegoMaster = WorksheetFunction.CountA(Sheets("Materiales Riego VC").Range("D:D"))
nextrowJardinesMaster = WorksheetFunction.CountA(Sheets("Materiales Jardines VC").Range("D:D"))
nextrowMaster = WorksheetFunction.CountA(Sheets("Materiales Master").Range("D:D"))
Sheets("Materiales Riego VC").Range(Cells(3, 1), Cells(nextrowRiegoMaster, 11)).Copy
Sheets("Materiales Master").Cells(nextrowMaster + 1, 1).PasteSpecial Paste:=xlPasteValues
nextrowMaster = WorksheetFunction.CountA(Sheets("Materiales Master").Range("D:D"))
Sheets("Materiales Jardines VC").Range(Cells(3, 1), Cells(nextrowJardinesMaster, 11)).Copy
Sheets("Materiales Master").Cells(nextrowMaster + 1, 1).PasteSpecial Paste:=xlPasteValues