Ver Mensaje Individual
  #3 (permalink)  
Antiguo 13/10/2011, 00:55
Avatar de gerardo_goh
gerardo_goh
 
Fecha de Ingreso: noviembre-2008
Mensajes: 107
Antigüedad: 15 años, 6 meses
Puntos: 1
Respuesta: De MYSQL a EXCEL

Hola pasalo a txt y posteriormente ejecuta esta macro, Saludos!!!

Código SQL:
Ver original
  1. [HTML]
  2. Sub ImportarArchivosTXTmuyLargos()
  3.  
  4. 'Dimension de variable
  5. Dim ResultStr As String
  6. Dim FileNum As Integer
  7. Dim Counter As Double
  8.  
  9. 'Abrir Archivo
  10. FileName = Application.GetOpenFilename _
  11.        (filefilter:="Archivos de Texto (*.txt),*.txt", Title:="Elegir Archivo")
  12. IF FileName = "" THEN END
  13. FileNum = FreeFile()
  14. OPEN FileName FOR INPUT AS #FileNum
  15.  
  16. Application.ScreenUpdating = FALSE
  17.  
  18. Workbooks.ADD template:=xlWorksheet
  19. Counter = 1
  20. Do While Seek(FileNum) <= LOF(FileNum)
  21.  
  22. Application.StatusBar = "Importing Row " & _
  23. Counter & " of text file " & FileName
  24.  
  25. Line INPUT #FileNum, ResultStr
  26.  
  27. IF LEFT(ResultStr, 1) = "=" THEN
  28. ActiveCell.VALUE = "'" & ResultStr
  29. ELSE
  30. ActiveCell.VALUE = ResultStr
  31. END IF
  32.  
  33.  
  34. IF ActiveCell.ROW = 1048576 THEN
  35.  
  36.    ActiveWorkbook.Sheets.ADD
  37. ELSE
  38.  
  39.    ActiveCell.Offset(1, 0).SELECT
  40. END IF
  41.  
  42. Counter = Counter + 1
  43.  
  44. Loop
  45.  
  46. Close
  47.  
  48. Application.StatusBar = FALSE
  49. END Sub[/HTML]


Me dices si te funciono