viernes, 4 de diciembre de 2020

Array resize - de matriu a tres columnes Macro VBA a Excel

Sub Macro1()

Dim CantFila As Long
Dim CantCol As Long
Dim c As Single, f As Single, m As Single
m = 1

CantFila = Cells(Rows.Count, 1).End(xlUp).Row
CantCol = Cells(1, Columns.Count).End(xlToLeft).Column

    
For c = 2 To CantCol Step 1
    For f = 2 To CantFila Step 1

    If (InStr(1, Cells(f, c).Value, "(no s'") <> 0) And (Left(Cells(f, 1).Value, 1) <> "2") And (Left(Cells(f, 1).Value, 3) <> "CtP") Then
        Cells(m, 27).Value = Cells(f, 1).Value
        Cells(m, 28).Value = Cells(1, c).Value
        Cells(m, 29).Value = Cells(f, c).Value
        m = m + 1
    End If

    Next f
Next c

End Sub










No hay comentarios:

Publicar un comentario