Advertisement
Guest User

Untitled

a guest
Dec 12th, 2019
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. Sub ImportarDadosCSV()
  2. 'Caminho do Arquivo
  3. FilePath = "C:\dados\teste.csv"
  4.  
  5. Open FilePath For Input As #1
  6.  
  7. row_number = 0 ' Variavel inicia com 0
  8.  
  9. Do Until EOF(1) 'Loop
  10.  
  11. Line Input #1, LineFromFile
  12. 'Selecionar a celula inicial que recebera os dados
  13. Range("A1").Select
  14.  
  15. ' Condicional para Limitar a Quantidade de linha percorrida
  16. If row_number <= 50 Then
  17.  
  18. LineItems = Split(LineFromFile, ",")
  19. 'Linhas / Colunas que receberão os dados importados
  20. ActiveCell.Range("A1:E20").Value = LineItems(0)
  21. 'Incrementa
  22. row_number = row_number + 1
  23. End If
  24. Loop
  25.  
  26. Close #1
  27.  
  28. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement