"El índice no pertenece a la selección" + VBA

fleur.31 Mensajes publicados 3 Estado Miembro -  
 geosevda -
Bonjour,
Tenemos un problema en la programación de nuestro VBA. Aquí está nuestro programa:

Sub Bloucle1Bull()
Dim a, k As Integer

k = 2
Do While Worksheets("formulario").Cells(2, 2) <> Worksheets("formulario").Cells(k, 4)
k = k + 1
Loop

a = 2
Do While Worksheets("formulario").Cells(k + 1, 4) <> Worksheets("BDD Call").Cells(a, 1) Or (Worksheets("BDD Call").Cells(a, 4) <= (Worksheets("bullspread").Cells(2, 3) - 100) Xor Worksheets("BDD Call").Cells(a, 4) >= (Worksheets("Bullspread").Cells(2, 3) + 100)) Or Worksheets("BDD Call").Cells(a, 7) <> Worksheets("bullspread").Cells(2, 7)
a = a + 1
Loop

''''''''''''se copia la línea de la primera llamada encontrada para el día 2 en bullspread'''''''

Worksheets("BDD Bullspread").Cells(3, 1) = Worksheets("BDD call").Cells(a, 1)
Worksheets("BDD Bullspread").Cells(3, 2) = Worksheets("BDD call").Cells(a, 3)
Worksheets("BDD Bullspread").Cells(3, 3) = Worksheets("BDD call").Cells(a, 4)
Worksheets("BDD Bullspread").Cells(3, 4) = Worksheets("BDD call").Cells(a, 5)
Worksheets("BDD Bullspread").Cells(3, 5) = Worksheets("BDD call").Cells(a, 6)
Worksheets("BDD Bullspread").Cells(3, 6) = Worksheets("BDD call").Cells(a, 7)
Worksheets("BDD Bullspread").Cells(3, 7) = Worksheets("BDD call").Cells(a, 8)
Worksheets("BDD Bullspread").Cells(3, 8) = Worksheets("BDD call").Cells(a, 9)
Worksheets("BDD Bullspread").Cells(3, 9) = Worksheets("BDD call").Cells(a, 10)

End Sub

Cuando ejecutamos la macro, aparece un mensaje diciendo que "el índice no pertenece a la selección"...

¿Alguien podría ayudarnos, por favor?

Configuración: Windows 7 / Internet Explorer 8.0

1 respuesta

  1. gregg5l Mensajes publicados 43 Fecha de registro   Estado Miembro Última intervención   28
     
    Hola;
    Cuando en VBA hay un error de tipo "el índice no pertenece a la selección", significa que el código no encuentra un libro o una hoja.
    Verifica por lo tanto los nombres de las hojas.
    Si los nombres son correctos, reemplaza Worksheets() por Sheets()
    23
    1. geosevda
       
      Hola, tengo el mismo mensaje de error, estoy intentando leer las líneas de un archivo de texto a través de un messagebox, el código es el siguiente:

      Dim oFSO As Scripting.FileSystemObject
      Dim oTxt As Scripting.TextStream
      With oTxt
      Dim TestArray() As String
      Dim st As String
      Dim i As Integer
      Dim tRows As Long
      Dim tCols As Long
      Dim ligne As AcadLine

      Set oFSO = New Scripting.FileSystemObject
      Set oTxt = oFSO.OpenTextFile(txtDWGname.Text, ForReading)

      With oTxt
      While Not .AtEndOfStream

      st = oTxt.ReadLine
      TestArray() = split(st, ";")
      Dim TestArrayField As Integer
      tRows = .Line
      tCols = .Column
      For i = 0 To tRows
      MsgBox TestArray(i)
      Next
      Wend

      End With
      oTxt.Close
      End With
      1