Hello,
I have a problem trying to codifying a copy paste a wide range of cells from one sheets with many formulas that are changing because there is a loop, to another sheet.
This is in my example:
First Part
Cash Flows from 1 to 246 that create a loop to generate a projection cash flows for each contract.
The problem is to copy paste these 246 rows with formulas that changed because the loop, to another sheet for each contract in this loop.
I created the following code:
Sub PRESTACIONES()
'
' PRESTACIONES Macro
'
Dim n As Single
Dim t As Single
n = Sheets("CÁLCULO PRESTACIONES").Range("b2").Value
t = Sheets("CÁLCULO PRESTACIONES").Range("b1").Value
Application.ScreenUpdating = False
' limpio las hojas
ThisWorkbook.Sheets("TOTAL PRESTACIONES").Range("a3100000").ClearContents
ThisWorkbook.Sheets("CÁLCULO PRESTACIONES").Activate
ThisWorkbook.Sheets("CUADRE PRESTACIONES").Activate
ThisWorkbook.Sheets("TOTAL PRESTACIONES").Activate
For t = 1 To n
ThisWorkbook.Sheets("CÁLCULO PRESTACIONES").Select
Sheets("CÁLCULO PRESTACIONES").Range("b1").Value = t
Application.StatusBar = "Procesando Registro " & t
ThisWorkbook.Sheets("CUADRE PRESTACIONES").Activate
ThisWorkbook.Sheets("CUADRE PRESTACIONES").Range("A3:K146").Select
Selection.Copy
ThisWorkbook.Sheets("TOTAL PRESTACIONES").Activate
ThisWorkbook.Sheets("TOTAL PRESTACIONES").Select
Range("a1").Select
Selection.Offset(t + 1).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Next
End Sub
So if you look at the last part where you can see "Range("A3:K146")", the code ends pasting the first row for each contract and the all ones for the final contract, but just the final contract (246), but not for the previous ones.
How can I solve this problem to paste the entire 246 rows for each contract and not only for last contract?
Thank you
I have a problem trying to codifying a copy paste a wide range of cells from one sheets with many formulas that are changing because there is a loop, to another sheet.
This is in my example:
First Part
Cash Flows from 1 to 246 that create a loop to generate a projection cash flows for each contract.
The problem is to copy paste these 246 rows with formulas that changed because the loop, to another sheet for each contract in this loop.
I created the following code:
Sub PRESTACIONES()
'
' PRESTACIONES Macro
'
Dim n As Single
Dim t As Single
n = Sheets("CÁLCULO PRESTACIONES").Range("b2").Value
t = Sheets("CÁLCULO PRESTACIONES").Range("b1").Value
Application.ScreenUpdating = False
' limpio las hojas
ThisWorkbook.Sheets("TOTAL PRESTACIONES").Range("a3100000").ClearContents
ThisWorkbook.Sheets("CÁLCULO PRESTACIONES").Activate
ThisWorkbook.Sheets("CUADRE PRESTACIONES").Activate
ThisWorkbook.Sheets("TOTAL PRESTACIONES").Activate
For t = 1 To n
ThisWorkbook.Sheets("CÁLCULO PRESTACIONES").Select
Sheets("CÁLCULO PRESTACIONES").Range("b1").Value = t
Application.StatusBar = "Procesando Registro " & t
ThisWorkbook.Sheets("CUADRE PRESTACIONES").Activate
ThisWorkbook.Sheets("CUADRE PRESTACIONES").Range("A3:K146").Select
Selection.Copy
ThisWorkbook.Sheets("TOTAL PRESTACIONES").Activate
ThisWorkbook.Sheets("TOTAL PRESTACIONES").Select
Range("a1").Select
Selection.Offset(t + 1).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Next
End Sub
So if you look at the last part where you can see "Range("A3:K146")", the code ends pasting the first row for each contract and the all ones for the final contract, but just the final contract (246), but not for the previous ones.
How can I solve this problem to paste the entire 246 rows for each contract and not only for last contract?
Thank you