Tengo una macro, pero quiero que esta se repita ciertas veces según el valor de una celda, como hacerlo?

Este es mi macro (código)

Sub PASO5()
'
' PASO5 Macro
' COPIAR VENTAS Y GRAVARLAS
'

'
Sheets("INFORMACION").Select
Cells.Select
Selection.Copy
Sheets("COPIA DE LAS VENTAS").Select
ActiveSheet.Paste
Application.CutCopyMode = False
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("VENTAS A IMPORTAR").Select
Rows("2:10").Select
Application.CutCopyMode = False
Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
Range("A2").Select
ActiveCell.FormulaR1C1 = "41353601"
Range("A3").Select
ActiveCell.FormulaR1C1 = "41353605"
Range("A4").Select
ActiveCell.FormulaR1C1 = "41353615"
Range("A5").Select
ActiveCell.FormulaR1C1 = "24080501"
Range("A6").Select
ActiveCell.FormulaR1C1 = "13551502"
Range("A7").Select
ActiveCell.FormulaR1C1 = "13551511"
Range("A8").Select
ActiveCell.FormulaR1C1 = "13559501"
Range("A9").Select
ActiveCell.FormulaR1C1 = "23657503"
Range("A10").Select
ActiveCell.FormulaR1C1 = "13050501"
Range("B2").Select
ActiveCell.FormulaR1C1 = "4"
Range("B3").Select
ActiveCell.FormulaR1C1 = "4"
Range("B4").Select
ActiveCell.FormulaR1C1 = "4"
Range("B5").Select
ActiveCell.FormulaR1C1 = "4"
Range("B6").Select
ActiveCell.FormulaR1C1 = "4"
Range("B7").Select
ActiveCell.FormulaR1C1 = "4"
Range("B8").Select
ActiveCell.FormulaR1C1 = "4"
Range("B9").Select
ActiveCell.FormulaR1C1 = "4"
Range("B10").Select
ActiveCell.FormulaR1C1 = "4"
Range("C2").Select
ActiveCell.FormulaR1C1 = "=INFORMACION!R2C8"
Range("C2").Select
Selection.AutoFill Destination:=Range("C2:C10"), Type:=xlFillDefault
Range("C2:C10").Select
Range("D2").Select
ActiveCell.FormulaR1C1 = "=INFORMACION!R2C7"
Range("D2").Select
Selection.AutoFill Destination:=Range("D2:E2"), Type:=xlFillDefault
Range("D2:E2").Select
Selection.AutoFill Destination:=Range("D2:E10"), Type:=xlFillDefault
Range("D2:E10").Select
Range("F2").Select
ActiveCell.FormulaR1C1 = "=+INFORMACION!R2C3"
Range("F2").Select
Selection.AutoFill Destination:=Range("F2:F10"), Type:=xlFillDefault
Range("F2:F10").Select
Range("G2").Select
ActiveCell.FormulaR1C1 = "VENTAS"
Range("G2").Select
Selection.AutoFill Destination:=Range("G2:G10"), Type:=xlFillDefault
Range("G2:G10").Select
Range("H2").Select
ActiveCell.FormulaR1C1 = "2"
Range("H3").Select
ActiveCell.FormulaR1C1 = "2"
Range("H4").Select
ActiveCell.FormulaR1C1 = "2"
Range("H5").Select
ActiveCell.FormulaR1C1 = "2"
Range("H6").Select
ActiveCell.FormulaR1C1 = "1"
Range("H7").Select
ActiveCell.FormulaR1C1 = "1"
Range("H8").Select
ActiveCell.FormulaR1C1 = "1"
Range("H9").Select
ActiveCell.FormulaR1C1 = "2"
Range("H10").Select
ActiveCell.FormulaR1C1 = "1"
Range("I2").Select
ActiveCell.FormulaR1C1 = "=+IF(INFORMACION!RC="""",0,INFORMACION!RC)"
Range("I3").Select
ActiveCell.FormulaR1C1 = _
"=+IF(INFORMACION!R[-1]C[1]="""",0,INFORMACION!R[-1]C[1])"
Range("I4").Select
ActiveCell.FormulaR1C1 = _
"=+IF(INFORMACION!R[-2]C[2]="""",0,INFORMACION!R[-2]C[2])"
Range("I5").Select
ActiveCell.FormulaR1C1 = _
"=+IF(INFORMACION!R[-3]C[3]="""",0,INFORMACION!R[-3]C[3])"
Range("I6").Select
ActiveCell.FormulaR1C1 = _
"=+IF(INFORMACION!R[-4]C[8]="""",0,INFORMACION!R[-4]C[8])"
Range("I7").Select
ActiveCell.FormulaR1C1 = _
"=+IF(INFORMACION!R[-5]C[7]="""",0,INFORMACION!R[-5]C[7])"
Range("I8").Select
ActiveCell.FormulaR1C1 = "SI"
Range("I8").Select
ActiveCell.FormulaR1C1 = _
"=+IF(INFORMACION!R[-6]C[4]="""",0,INFORMACION!R[-6]C[4])"
Range("I9").Select
ActiveCell.FormulaR1C1 = "=+R[-1]C"
Range("I10").Select
ActiveCell.FormulaR1C1 = "=+R[-8]C+R[-7]C+R[-6]C+R[-5]C-R[-4]C-R[-3]C"
Range("J5").Select
ActiveCell.FormulaR1C1 = "=+IF(RC[-1]=0,0,RC[-1]/16%)"
Range("J6").Select
ActiveCell.FormulaR1C1 = "=+IF(RC[-1]=0,0,RC[-1]/'DATOS GENERALES'!R[1]C[-8])"
Range("J7").Select
ActiveCell.FormulaR1C1 = "=+IF(RC[-1]=0,0,RC[-1]/'DATOS GENERALES'!R[-4]C[-8])"
Range("J8").Select
ActiveCell.FormulaR1C1 = "=+IF(RC[-1]=0,0,RC[-1]/'DATOS GENERALES'!R[-7]C[-8])"
Range("J9").Select
ActiveCell.FormulaR1C1 = "=+R[-1]C"
Range("J10").Select
ActiveCell.FormulaR1C1 = "0"
Range("J2").Select
ActiveCell.FormulaR1C1 = "0"
Range("J3").Select
ActiveCell.FormulaR1C1 = "0"
Range("J4").Select
ActiveCell.FormulaR1C1 = "0"
Rows("2:10").Select
Selection.Font.Bold = False
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("INFORMACION").Select
Rows("2:2").Select
Application.CutCopyMode = False
Selection.Delete Shift:=xlUp
Sheets("MACROS").Select
End Sub

como le agrego el bucle, teniendo en cuenta que la celda que tiene el valor (que quiero que se repita) esta en la "E2" en la hoja "DATOS"

muchas gracias de antemano.

1 respuesta

Respuesta

Yo lo que haría es definir una variable

dim cant as integer

y despues un for y metes todo adentro

for i=1 to cant

Pones todo lo del medio

Y después

next

Cualquier cosa avisame

Si resolvió tu problema no olvides calificarme

Quería saber si se resolvió tu problema

Añade tu respuesta

Haz clic para o

Más respuestas relacionadas