getting error for copy paste logic vba

drop05

Active Member
Joined
Mar 23, 2021
Messages
285
Office Version
  1. 365
Platform
  1. Windows
Hello i am trying to paste a formula into a cell, then copy and paste that formula a few columns down but i am getting a run time error 1004 in my code and not sure why or what needs to be edited

VBA Code:
Sub Formula_change()

Dim rowNum, ColAmt, colNum, colOff, i As Integer

rowNum = 44
ColAmt = 4
colNum = 4
colOff = 2
i = 2

Dim main As Workbook
Set main = Application.ThisWorkbook
Dim main_ws As Worksheet

Dim page1 As Worksheet
Set page1 = main.Worksheets("Page 1")

page1.Range("F2").FormulaR1C1 = "=IF(IFERROR(VLOOKUP(R[-37]C[-1],'List'!R4C7:R200C18,12,FALSE),0)=""Please fill out"",""--"",IFERROR(VLOOKUP(R[-37]C[-1],'List'!R4C7:R200C18,12,FALSE),0))"

Application.CutCopyMode = False
page1.Range("F2").Copy
page1.Range(2, (((i - 1) * (ColAmt)) + colNum) + colOff).Paste

I am getting a run time error 1004 method range of object worksheet failed error here at:
page1.Range(2, (((i - 1) * (ColAmt)) + colNum) + colOff).Paste
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
can cancel the above request i needed it to be .cells and not .range there and it fixed it thank you anyways!
 
Upvote 0

Forum statistics

Threads
1,224,822
Messages
6,181,165
Members
453,021
Latest member
Justyna P

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