Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Sub ImportarDadosCSV()
- 'Caminho do Arquivo
- FilePath = "C:\dados\teste.csv"
- Open FilePath For Input As #1
- row_number = 0 ' Variavel inicia com 0
- Do Until EOF(1) 'Loop
- Line Input #1, LineFromFile
- 'Selecionar a celula inicial que recebera os dados
- Range("A1").Select
- ' Condicional para Limitar a Quantidade de linha percorrida
- If row_number <= 50 Then
- LineItems = Split(LineFromFile, ",")
- 'Linhas / Colunas que receberão os dados importados
- ActiveCell.Range("A1:E20").Value = LineItems(0)
- 'Incrementa
- row_number = row_number + 1
- End If
- Loop
- Close #1
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement