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.

Copiar una fila de excel a otro archivo excel incrementalmente tras ejecutar Macro

publicado

Hola,

he ido leyendo varios hilos pero ninguno contesta exactamente a lo que quiero hacer.

Tengo cientos de archivos excel, cada uno de ellos con una sóla columna, a los que les tengo que aplicar varias funciones estadísticas, siempre las mismas. Como es hiper reiterativo, he creado una macro. Así pues, al ejecutarlo, el resultado me aparece en la fila (A1:A20) es decir 20 datos. Esos datos interminablemente los tengo que copiar y pegar en otra hoja excel, e ir añadiéndolos en filas incrementales (fila A1, A2, ....Aenésima)

Me estoy desesperando.

Alguién me puede pasar un pequeño código para que al terminar el primer macro me copie directamente los datos de la fila (A1:A20) al otro archivo excel, o a un txt que luego pase a excel, para finalmente tener un archivo excel con los cientos de filas (A1:A20) donde posteriormente tendré que hacer otras operaciones. Aunque esto ya es problema mío.

Gracias!

Esto lo tengo que hacer con un montón de archivos diferentes y macros diferentes, pongo aquí la macro más sencilla, generado con el record

Sub Macro1()

'

' Macro1 Macro

'

' Keyboard Shortcut: Ctrl+a

'

Range("D1").Select

ActiveCell.FormulaR1C1 = "Elección 1"

Range("E1").Select

ActiveCell.FormulaR1C1 = ""

Range("D1").Select

ActiveCell.FormulaR1C1 = "Eleccion_1"

Range("D2").Select

Columns("D:D").ColumnWidth = 12.14

Range("E1").Select

ActiveCell.FormulaR1C1 = "Eleccion_2"

Rows("1:1").Select

Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove

Range("D3").Select

ActiveCell.FormulaR1C1 = "=+COUNTIF(RC[-2]:R[14]C[-2],1)"

Range("D3").Select

Selection.AutoFill Destination:=Range("D3:E3"), Type:=xlFillDefault

Range("D3:E3").Select

Range("D3").Select

ActiveCell.FormulaR1C1 = "=+COUNTIF(R3C2:R17C2,1)"

Range("D3").Select

Selection.AutoFill Destination:=Range("D3:E3"), Type:=xlFillDefault

Range("D3:E3").Select

Range("E3").Select

ActiveCell.FormulaR1C1 = "=+COUNTIF(R3C2:R17C2,2)"

Range("E4").Select

Columns("E:E").ColumnWidth = 10.29

Range("D1:E1").Select

With Selection

.HorizontalAlignment = xlCenter

.VerticalAlignment = xlBottom

.WrapText = False

.Orientation = 0

.AddIndent = False

.IndentLevel = 0

.ShrinkToFit = False

.ReadingOrder = xlContext

.MergeCells = False

End With

Selection.Merge

ActiveCell.FormulaR1C1 = "Total"

Range("F1:G1").Select

With Selection

.HorizontalAlignment = xlCenter

.VerticalAlignment = xlBottom

.WrapText = False

.Orientation = 0

.AddIndent = False

.IndentLevel = 0

.ShrinkToFit = False

.ReadingOrder = xlContext

.MergeCells = False

End With

Selection.Merge

ActiveCell.FormulaR1C1 = "Primer tercio"

Range("F1:G1").Select

Selection.Copy

Range("H1").Select

ActiveSheet.Paste

Range("J1").Select

ActiveSheet.Paste

Range("H1:I1").Select

Application.CutCopyMode = False

ActiveCell.FormulaR1C1 = "Segundo tercio"

Range("J1:K1").Select

ActiveCell.FormulaR1C1 = "Tercer tercio"

Range("D2:E2").Select

Selection.Copy

Range("F2").Select

ActiveSheet.Paste

Range("H2").Select

ActiveSheet.Paste

Range("J2").Select

Columns("F:F").ColumnWidth = 13.71

Columns("G:G").ColumnWidth = 11.86

Range("K3").Select

Columns("H:H").ColumnWidth = 10.57

Range("F2:G2").Select

Application.CutCopyMode = False

Selection.Copy

Range("J2").Select

ActiveSheet.Paste

Columns("D:K").Select

Range("D2").Activate

Selection.ColumnWidth = 11.43

Range("D3:E3").Select

Application.CutCopyMode = False

Selection.AutoFill Destination:=Range("D3:K3"), Type:=xlFillDefault

Range("D3:K3").Select

ActiveCell.FormulaR1C1 = "=+COUNTIF(R3C2:R7C2,1)"

Range("F3").Select

ActiveCell.FormulaR1C1 = "=+COUNTIF(R3C2:R7C2,1)"

Range("G3").Select

ActiveCell.FormulaR1C1 = "=+COUNTIF(R3C2:R7C2,2)"

Range("H3").Select

ActiveCell.FormulaR1C1 = "=+COUNTIF(R8C2:R12C2,1)"

Range("I3").Select

ActiveCell.FormulaR1C1 = "=+COUNTIF(R8C2:R12C2,2)"

Range("J3").Select

ActiveCell.FormulaR1C1 = "=+COUNTIF(R13C2:R17C2,1)"

Range("K3").Select

ActiveCell.FormulaR1C1 = "=+COUNTIF(R13C2:R17C2,2)"

Range("D3").Select

ActiveCell.FormulaR1C1 = "=+COUNTIF(R3C2:R17C2,1)"

Range("N4").Select

End Sub

Featured Replies

No hay posts para mostrar

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.