Saltar al contenido
View in the app

A better way to browse. Learn more.

Ayuda Excel

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

importar varios archivos txt a una hoja de excel

publicado

Buenas noches...

Mi nombre es JuanCarlos, soy nuevo en el foro y de igual manera no soy experto en programación, tengo el siguiente problema con Excel 2010, pido su colaboración.. gracias.

problema:

1. importar de varios archivos .txt (txt1, txt2, txt3, etc) a la hoja_1 de un Libro de Excel 2010 la información de manera consecutiva... es decir el txt1 estará desde la fila A1 hasta la fila que sea necesario (no determinado *3), siguiente fila continua el txt2 hasta fila necesaria (*3) y así sucesivamente....

2. cada archivo txt contiene los mismos campos y estructura, separados por comas.

*3. el Rango de filas de cada txt es variable, algunos contiene 20 registros, otros mas de 50.

Soluciones encontradas:

1. con la siguiente macro encontrada en Google, logre la importación de los archivos, pero lo realiza a varias hojas de excel de un mismo libro, es decir, txt1 a hoja1, txt2 a hoja 2, etc...

Sub abrir_txt()

On Error Resume Next

milibro = ActiveWorkbook.Name

Set navegador = CreateObject("shell.application")

carpeta = navegador.browseforfolder(0, "SELECCIONA CARPETA", 0, "c:\").items.Item.Path

ChDir carpeta & "\"

archi = Dir("*.txt")

Do While archi <> ""

Workbooks.OpenText archi, origin:=xlWindows, startrow:=1, DataType:=xlDelimited

otro = ActiveWorkbook.Name

ActiveSheet.Copy before:=Workbooks(milibro).Sheets(1)

Workbooks(otro).Close False

archi = Dir()

Loop

End Sub

2. utilice el Grabador de Macros para realizar el procedimiento necesitado de un solo archivo TXT, el mismo genera las columnas que se necesitan...

Sub import_bak()

'

' import_bak Macro

'

' Atalho por teclado: Ctrl+k

'

With ActiveSheet.QueryTables.Add(Connection:= _

"TEXT;C:\Users\Juan\Documents\informe.txt", Destination:= _

Range("$A$1"))

.CommandType = 0

.Name = "01=01072011"

.FieldNames = True

.RowNumbers = False

.FillAdjacentFormulas = False

.PreserveFormatting = True

.RefreshOnFileOpen = False

.RefreshStyle = xlInsertDeleteCells

.SavePassword = False

.SaveData = True

.AdjustColumnWidth = True

.RefreshPeriod = 0

.TextFilePromptOnRefresh = False

.TextFilePlatform = 850

.TextFileStartRow = 1

.TextFileParseType = xlDelimited

.TextFileTextQualifier = xlTextQualifierDoubleQuote

.TextFileConsecutiveDelimiter = False

.TextFileTabDelimiter = False

.TextFileSemicolonDelimiter = False

.TextFileCommaDelimiter = True

.TextFileSpaceDelimiter = False

.TextFileColumnDataTypes = Array(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, _

1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 _

, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, _

1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1)

.TextFileTrailingMinusNumbers = True

.Refresh BackgroundQuery:=False

End With

End Sub

........

Agradezco su ayuda.... mi correo electronico juan.carlos@hotmail.com

Featured Replies

Archivado

Este tema está ahora archivado y está cerrado a más respuestas.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.