Read a column in Excel

0

Good afternoon, how can I read a specific row-column? For example, I only want to read two columns in specific, D8 up to D15 and G8 up to G15 .

If you could guide me or if they had the code, it would be useful, thank you.

    
asked by Willy DO 03.06.2017 в 00:20
source

1 answer

0

you can read the values that have those cells in specific using this code

Assuming the data you have is on sheet 1:

Public Sub Lectura()
'Se declara el array que va a contener tus datos, el 500 es el maximo de datos que va a contener.

Dim Columna1(500), Columna2(500) As String
'El numero de fila donde estan tus datos

i = 8

Do While Hoja1.Cells(i, 4) <> "" 'el 4 es el numero de la columna

Columna1(i) = Hoja1.Cells(i, 4)

i = i + 1

Loop

i = 8

Do While Hoja1.Cells(i, 7) <> "" 'el 7 es el numero de la columna

    Columna2(i) = Hoja1.Cells(i, 7)

    i = i + 1

Loop

For i = 8 To 500

If Columna1(i) = "" And Columna1(i) = "" Then

Exit For

End If

Debug.Print Columna1(i) & "    " & Columna2(i)

Next

End Sub
    
answered by 16.06.2017 в 18:12