Macros: Using For, Looping through Rows and Columns

แชร์
ฝัง
  • เผยแพร่เมื่อ 15 ก.ย. 2024
  • Hello, in this series of videos you will be able to see some important points about how to code macros from VBA, in this video you will learn the use of the For instruction and how it helps us to generate repetitive cycles of instructions
    We will loop through rows and columns, filling in the value of the cells we loop through
    If you liked the video, please leave your like, comment and subscribe!!

ความคิดเห็น • 9

  • @smayker5847
    @smayker5847 2 ปีที่แล้ว +1

    Muy interesante y buena explicación. Gracias.

  • @arathmoreno1960
    @arathmoreno1960 2 ปีที่แล้ว

    Muy buena explicación!! Un suscriptor más!! Saludos

  • @joseignaciopinomondeja6105
    @joseignaciopinomondeja6105 2 ปีที่แล้ว

    Muy bueno. Gracias.

  • @elmorocho4502
    @elmorocho4502 2 ปีที่แล้ว

    Excelente ejercicio

  • @juangaytan2719
    @juangaytan2719 2 ปีที่แล้ว

    Gracias!!!

  • @gramos73
    @gramos73 ปีที่แล้ว

    Que bucles son mas rapidos?

  • @user-pc8jx6tx4n
    @user-pc8jx6tx4n 10 หลายเดือนก่อน

    muy buen video, mi pregunta es tengo una macro de vba que me agrega datos masivos pero cuando quiero insertar datos en la segunda columna me los manda abajo y no al principio como en la columna 1, cual seria la solución, codigo:
    Sub AltaMasiva()
    Dim hojaOrigen As Worksheet
    Dim tablaOrigen As ListObject
    Dim hojaDatos As Worksheet
    Dim tabla As ListObject
    Dim nuevaFila As ListRow
    Dim filasOrigen, i
    Dim pregunta As Byte
    Set hojaOrigen = ThisWorkbook.Sheets("Registro")
    Set tablaOrigen = hojaOrigen.ListObjects("registros")
    filasOrigen = tablaOrigen.ListRows.Count
    Set hojaDatos = ThisWorkbook.Sheets("Dias")
    Set tabla = hojaDatos.ListObjects("dias")
    For i = 1 To filasOrigen
    Set nuevaFila = tabla.ListRows.Add

    With tablaOrigen.ListRows(i)
    nuevaFila.Range(1) = .Range(1).Value
    nuevaFila.Range(2) = .Range(2).Value
    nuevaFila.Range(3) = .Range(3).Value
    nuevaFila.Range(4) = .Range(4).Value
    nuevaFila.Range(5) = .Range(5).Value
    nuevaFila.Range(6) = .Range(6).Value
    nuevaFila.Range(7) = .Range(7).Value
    nuevaFila.Range(8) = .Range(8).Value
    End With
    Next i
    MsgBox "Se guardaron los valores en tabla destino", vbInformation
    pregunta = MsgBox("Deseas limpiar los valores de la tabla registro?", vbYesNo + vbQuestion)
    If pregunta = vbNo Then Exit Sub
    If tablaOrigen.ListRows.Count >= 1 Then
    tablaOrigen.DataBodyRange.Delete
    End If
    End Sub