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

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
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,214,789
Messages
6,121,605
Members
449,038
Latest member
Arbind kumar

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