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.

cambiar rango hasta la última celda con datos

publicado

Hola a todos!!

He grabado la siguiente macro pero  cuando quiero cambiar la sentencia me da error.

"Selection.AutoFill Destination:=Range("K2:K631256")
    Range("K2:K631256").Select

Selection.AutoFill Destination:=Range("K2").End(xlDow)
    Range("K2").End(xlDow).Select

 

Os pongo la macro entera a continuación. 

Muchas gracias de antemano por la ayuda.

 

Sub AÑADIRFORMULASFUENTEDEDATOS()
'
    Columns("J:J").Select
    Selection.TextToColumns Destination:=Range("J1"), DataType:=xlDelimited, _
        TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, _
        Semicolon:=False, Comma:=False, Space:=False, Other:=True, OtherChar _
        :=".", FieldInfo:=Array(Array(1, 2), Array(2, 1)), TrailingMinusNumbers:=True
    Columns("K:K").Select
    Selection.Delete Shift:=xlToLeft
    Range("K1").Select
    With Selection.Interior
        .Pattern = xlSolid
        .PatternColorIndex = xlAutomatic
        .Color = 255
        .TintAndShade = 0
        .PatternTintAndShade = 0
    End With
    With Selection
        .HorizontalAlignment = xlCenter
        .VerticalAlignment = xlBottom
        .WrapText = False
        .Orientation = 0
        .AddIndent = False
        .ShrinkToFit = False
        .ReadingOrder = xlContext
        .MergeCells = False
    End With
    ActiveCell.FormulaR1C1 = "NUM_MES"
    Range("J3").Select
    Columns("K:K").ColumnWidth = 42.57
    Range("K2").Select
    ActiveCell.FormulaR1C1 = _
        "=VLOOKUP(CONCATENATE(YEAR(RC[-2]),""_"",MONTH(RC[-2])),AUX!R1C1:R25C2,2,FALSE)"
    Range("K2").Select
    Selection.AutoFill Destination:=Range("K2:K631256")
    Range("K2:K631256").Select
    Columns("K:K").ColumnWidth = 24.43
    Range("L1").Select
    Columns("L:L").ColumnWidth = 23.43
    With Selection.Interior
        .Pattern = xlSolid
        .PatternColorIndex = xlAutomatic
        .Color = 255
        .TintAndShade = 0
        .PatternTintAndShade = 0
    End With
    With Selection
        .HorizontalAlignment = xlCenter
        .VerticalAlignment = xlBottom
        .WrapText = False
        .Orientation = 0
        .AddIndent = False
        .ShrinkToFit = False
        .ReadingOrder = xlContext
        .MergeCells = False
    End With
    ActiveCell.FormulaR1C1 = "DÍA DE LA SEMANA"
    Range("L2").Select
    ActiveCell.FormulaR1C1 = "=WEEKDAY(RC[-3],11)"
    Range("L2").Select
    Selection.AutoFill Destination:=Range("L2:L631256")
    Range("L2:L631256").Select
    Range("M1").Select
    With Selection.Interior
        .Pattern = xlSolid
        .PatternColorIndex = xlAutomatic
        .Color = 255
        .TintAndShade = 0
        .PatternTintAndShade = 0
    End With
    With Selection
        .HorizontalAlignment = xlCenter
        .VerticalAlignment = xlBottom
        .WrapText = False
        .Orientation = 0
        .AddIndent = False
        .ShrinkToFit = False
        .ReadingOrder = xlContext
        .MergeCells = False
    End With
    ActiveCell.FormulaR1C1 = "HORA"
    Range("M2").Select
    ActiveCell.FormulaR1C1 = "=HOUR(RC[-3])"
    Range("M2").Select
    Selection.AutoFill Destination:=Range("M2:M631256")
    Range("M2:M631256").Select
    ActiveWindow.SmallScroll Down:=-15
    Range("K2:M2").Select
    Range(Selection, Selection.End(xlDown)).Select
    Selection.Copy
    ActiveWindow.SmallScroll Down:=-60
    ActiveWindow.ScrollRow = 631224
    ActiveWindow.ScrollRow = 211054
    ActiveWindow.ScrollRow = 122954
    ActiveWindow.ScrollRow = 3874
    ActiveWindow.ScrollRow = 2
    ActiveWindow.SmallScroll Down:=-6
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
End Sub
 

 

 

Featured Replies

publicado

Selection.AutoFill Destination:=Range(Range("K2"), Range("K2").End(xlDow))

Range(Range("K2"), Range("K2").End(xlDow)).Select

publicado
  • Autor

Hola Antoni!

Muchas gracias por tu ayuda, pero me sigue saliendo el mismo error "error definido por la aplicación o el objeto"

Adjunto el fichero de prueba por si le sirve de mejor guía.

Muchas gracias de nuevo

PRUEBA.xlsm

publicado

Selection.AutoFill Destination:=Range(Range("K2"), Range("K2").End(xlDown))

Range(Range("K2"), Range("K2").End(xlDown)).Select

Revisa toda la macro por si hubiera más instrucciones con este error.

Si no te funciona, comentas.

Editado el por Antoni

publicado
  • Autor

muchas gracias!! funciona a la perfección

 

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.