Runtime error 9, index does not belong to the selection.
Solved
isidoh
Posted messages
11
Status
Membre
-
isidoh Posted messages 11 Status Membre -
isidoh Posted messages 11 Status Membre -
Hello,
I have a small coding problem,
Basically, I would like to copy the values from certain cells of all the worksheets (89) of the workbook "Copie de MASTERFILE BASF Serie_Sept to Dec 2012_V2.xls" to another workbook I named "BDD" on the sheet also named BDD.
Here is the code I wrote:
Sub Macro()
Dim i As Integer
Dim k As Integer
Dim ws As Worksheet
For i = 2 To 90
For j = 3 To 91
'
Workbooks("BDD").Sheets("BDD").Range("A" & i).Value = Workbooks("Copie de MASTERFILE BASF Serie_Sept to Dec 2012_V2.xls").Sheets("Feuil").Range("C12")
Workbooks("BDD").Sheets("BDD").Range("C" & i).Value = Workbooks("Copie de MASTERFILE BASF Serie_Sept to Dec 2012_V2.xls").Sheets("Feuil").Range("C61")
Workbooks("BDD").Sheets("BDD").Range("F" & i).Value = Workbooks("Copie de MASTERFILE BASF Serie_Sept to Dec 2012_V2.xls").Sheets("Feuil").Range("V43")
Workbooks("BDD").Sheets("BDD").Range("G" & i).Value = Workbooks("Copie de MASTERFILE BASF Serie_Sept to Dec 2012_V2.xls").Sheets("Feuil").Range("F43")
Workbooks("BDD").Sheets("BDD").Range("H" & i).Value = Workbooks("Copie de MASTERFILE BASF Serie_Sept to Dec 2012_V2.xls").Sheets("Feuil").Range("B27")
Workbooks("BDD").Sheets("BDD").Range("I" & i).Value = Workbooks("Copie de MASTERFILE BASF Serie_Sept to Dec 2012_V2.xls").Sheets("Feuil").Range("C27")
Workbooks("BDD").Sheets("BDD").Range("J" & i).Value = Workbooks("Copie de MASTERFILE BASF Serie_Sept to Dec 2012_V2.xls").Sheets("Feuil").Range("E48")
Workbooks("BDD").Sheets("BDD").Range("K" & i).Value = Workbooks("Copie de MASTERFILE BASF Serie_Sept to Dec 2012_V2.xls").Sheets("Feuil").Range("C55")
Workbooks("BDD").Sheets("BDD").Range("M" & i).Value = Workbooks("Copie de MASTERFILE BASF Serie_Sept to Dec 2012_V2.xls").Sheets("Feuil").Range("F54")
Workbooks("BDD").Sheets("BDD").Range("N" & i).Value = Workbooks("Copie de MASTERFILE BASF Serie_Sept to Dec 2012_V2.xls").Sheets("Feuil").Range("F86")
Workbooks("BDD").Sheets("BDD").Range("O" & i).Value = Workbooks("Copie de MASTERFILE BASF Serie_Sept to Dec 2012_V2.xls").Sheets("Feuil").Range("E89")
Workbooks("BDD").Sheets("BDD").Range("P" & i).Value = Workbooks("Copie de MASTERFILE BASF Serie_Sept to Dec 2012_V2.xls").Sheets("Feuil").Range("F93")
Workbooks("BDD").Sheets("BDD").Range("Q" & i).Value = Workbooks("Copie de MASTERFILE BASF Serie_Sept to Dec 2012_V2.xls").Sheets("Feuil").Range("E90")
Next j
Next
End Sub
And when I run it, the message: runtime error 9, the index is out of range appears
Unfortunately, I couldn't find a solution, so your help would be greatly appreciated.
Thank you in advance
Configuration: Windows XP / Firefox 16.0
I have a small coding problem,
Basically, I would like to copy the values from certain cells of all the worksheets (89) of the workbook "Copie de MASTERFILE BASF Serie_Sept to Dec 2012_V2.xls" to another workbook I named "BDD" on the sheet also named BDD.
Here is the code I wrote:
Sub Macro()
Dim i As Integer
Dim k As Integer
Dim ws As Worksheet
For i = 2 To 90
For j = 3 To 91
'
Workbooks("BDD").Sheets("BDD").Range("A" & i).Value = Workbooks("Copie de MASTERFILE BASF Serie_Sept to Dec 2012_V2.xls").Sheets("Feuil").Range("C12")
Workbooks("BDD").Sheets("BDD").Range("C" & i).Value = Workbooks("Copie de MASTERFILE BASF Serie_Sept to Dec 2012_V2.xls").Sheets("Feuil").Range("C61")
Workbooks("BDD").Sheets("BDD").Range("F" & i).Value = Workbooks("Copie de MASTERFILE BASF Serie_Sept to Dec 2012_V2.xls").Sheets("Feuil").Range("V43")
Workbooks("BDD").Sheets("BDD").Range("G" & i).Value = Workbooks("Copie de MASTERFILE BASF Serie_Sept to Dec 2012_V2.xls").Sheets("Feuil").Range("F43")
Workbooks("BDD").Sheets("BDD").Range("H" & i).Value = Workbooks("Copie de MASTERFILE BASF Serie_Sept to Dec 2012_V2.xls").Sheets("Feuil").Range("B27")
Workbooks("BDD").Sheets("BDD").Range("I" & i).Value = Workbooks("Copie de MASTERFILE BASF Serie_Sept to Dec 2012_V2.xls").Sheets("Feuil").Range("C27")
Workbooks("BDD").Sheets("BDD").Range("J" & i).Value = Workbooks("Copie de MASTERFILE BASF Serie_Sept to Dec 2012_V2.xls").Sheets("Feuil").Range("E48")
Workbooks("BDD").Sheets("BDD").Range("K" & i).Value = Workbooks("Copie de MASTERFILE BASF Serie_Sept to Dec 2012_V2.xls").Sheets("Feuil").Range("C55")
Workbooks("BDD").Sheets("BDD").Range("M" & i).Value = Workbooks("Copie de MASTERFILE BASF Serie_Sept to Dec 2012_V2.xls").Sheets("Feuil").Range("F54")
Workbooks("BDD").Sheets("BDD").Range("N" & i).Value = Workbooks("Copie de MASTERFILE BASF Serie_Sept to Dec 2012_V2.xls").Sheets("Feuil").Range("F86")
Workbooks("BDD").Sheets("BDD").Range("O" & i).Value = Workbooks("Copie de MASTERFILE BASF Serie_Sept to Dec 2012_V2.xls").Sheets("Feuil").Range("E89")
Workbooks("BDD").Sheets("BDD").Range("P" & i).Value = Workbooks("Copie de MASTERFILE BASF Serie_Sept to Dec 2012_V2.xls").Sheets("Feuil").Range("F93")
Workbooks("BDD").Sheets("BDD").Range("Q" & i).Value = Workbooks("Copie de MASTERFILE BASF Serie_Sept to Dec 2012_V2.xls").Sheets("Feuil").Range("E90")
Next j
Next
End Sub
And when I run it, the message: runtime error 9, the index is out of range appears
Unfortunately, I couldn't find a solution, so your help would be greatly appreciated.
Thank you in advance
Configuration: Windows XP / Firefox 16.0
7 réponses
Hello,
If you want the j loop to go through the tabs of "copy of masterfile", this variable needs to be part of the referencing of the tabs in this workbook.
Workbooks("BDD").Sheets("BDD").Range("A" & i).Value = Workbooks("Copy of MASTERFILE BASF Serie_Sept to Dec 2012_V2.xls").Sheets("Sheet" & j).Range("C12")
See you later.
If you want the j loop to go through the tabs of "copy of masterfile", this variable needs to be part of the referencing of the tabs in this workbook.
Workbooks("BDD").Sheets("BDD").Range("A" & i).Value = Workbooks("Copy of MASTERFILE BASF Serie_Sept to Dec 2012_V2.xls").Sheets("Sheet" & j).Range("C12")
See you later.
I have already made this change; however, the error does not come from there.
Thank you.