Saludos Sr. @Héctor Miguel agradecido por sus comentarios.
Un poco de contexto, el resultado, que pretendo obtener en la Celda "E11" dependiendo de las horas introducidas en en la Celda "D11" me permite obtener los descansos obligatorios por Ley para periodos de tiempo determinados de alli que estoy tomando los cuatro casos más comunes, por tal motivo la Celda "D11" solo podrá adquirir valores comprendidos entre las 0 Horas y las 28 Horas mientas que la Celda "E11" exclusivamente podrá reflejar como resultado cuatro valores 0, 1, 2 y 3, ya que siendo un requisito legal no existe la posibilidad de obtener otro resultado si los valores de la Celda "D11" están comprendidos entre 0 Horas y 28 Horas, para acotar más el resultado y no dejar intervalos abiertos modifique la última fórmula:
=SI(Y($D8>=21;$D8<29);3;0)
Adjunto nuevamente el archivo con las correcciones mencionadas así como con los resultados esperados conforme me solicitó.
Libro1_110914.xlsx
Por
jues, · 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