Ver Mensaje Individual
  #4 (permalink)  
Antiguo 17/03/2009, 03:17
Avatar de 3pies
3pies
Colaborador
 
Fecha de Ingreso: diciembre-2003
Ubicación: Desde una destilería
Mensajes: 2.584
Antigüedad: 20 años, 5 meses
Puntos: 144
Respuesta: Problema Excel

A mí esto me funciona perfectamente:
Código:
Sub prueba()
numRegistros = 10
For row2 = 4 To numRegistros
If Cells(row2, 2).Value = "1" Then
    Range(Cells(row2, 3), Cells(row2, 6)).Select
    Selection.Copy
    Sheets("Hoja2").Select
    ActiveSheet.Range(Cells(row2, 3), Cells(row2, 6)).Select
    ActiveSheet.Paste
    Sheets("Hoja1").Select
End If
Next
End Sub
Es raro eso que te ocurre. Comprueba que la variable "numRegistros" esté informada, y que no tengas otra parte del código que entre en conflicto con algo.

Si eliges la otra opción que no te da error, prueba cambiando el código así:
Código:
Sub prueba2()
numRegistros = 10
For row2 = 4 To numRegistros
If Cells(row2, 2).Value = "1" Then
    fila = Cells(row2, 2).Row
    columna = Cells(row2, 2).Column
    Range(Cells(row2, 3), Cells(row2, 6)).Select
    Selection.Copy
    Sheets("Hoja2").Select
    ActiveSheet.Range(Cells(fila, columna + 1), Cells(fila, 6)).Select
    ActiveSheet.Paste
    Sheets("Hoja1").Select
End If
Next
End Sub
Ojo, yo he asignado numRegistros = 10, para hacer pruebas.