problem with an array loop

KatyJohn

New Member
Joined
Jan 25, 2009
Messages
41
Need help

I'm getting an error 1004 on this array loop below. The loop has worked in another application. Not sure why it doesn't work here.


Dim FromRng, ToRng
Dim i As Integer
Dim NewQuoteFile As String
Dim NewQuotePage As String


NewQuoteFile = Range("BF21")

NewQuotePage = Range("BF20")

FromRng = Array("BI22", "BI23", "BI24", "BI25", "BI26", "BI27", "BI28", "BI29", "BI31")
ToRng = Array("B12", "B15", "B16", "B17", "B18", "C20", "F21", "B23", "C45")
For i = LBound(FromRng) To UBound(FromRng)

Workbooks("2009 Quote Form.xlsm").Sheets("Module Number Entry").Range(FromRng(i)).Copy Destination:=Workbooks(NewQuoteFile).Sheets("Intro Letter").Range(ToRng(i))
Next i
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number

Colin Legg

MrExcel MVP
Joined
Feb 28, 2008
Messages
3,497
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
What is the runtime error message? Are the workbook and worksheet names definitely valid and are all the relevant workbooks open when the code runs?
 
Upvote 0

Forum statistics

Threads
1,191,534
Messages
5,987,142
Members
440,082
Latest member
belodelokelo

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