# Copy Paste Formula

#### vmjan02

##### Well-known Member
I have formulas In cells I14, K14, L14, M14, N14 and O14 (All the formulas are different).

Is there a code where it will copy the formula till last non blank cell in Column H (in this record starts from H14).

I tried below code, but it is taking lot of time. Is there any other way as the formula is not limited to O14 , it is till CS14
Just need a different way as the execution of code is faster.
VBA Code:
``````With Worksheets("Intraday -EOD Stats")
With .Range("I14:I" & .Range("H" & .Rows.Count).End(xlUp).Row)
.Formula = "=IF(\$H14<=\$D\$12,SUMIFS(INDIRECT(\$A\$6&\$B\$5),INDIRECT(\$A\$6&\$C\$5),\$C14,INDIRECT(\$A\$6&\$D\$5),\$H14))"
.Value = .Value
'.NumberFormat = "DD-MM-YYYY"
End With
End With

With Worksheets("Intraday -EOD Stats")
With .Range("K14:K" & .Range("H" & .Rows.Count).End(xlUp).Row)
.Formula = "=SUMIFS(INDIRECT(\$A\$2&K\$1),INDIRECT(\$A\$2&\$B\$2),\$C14,INDIRECT(\$A\$2&\$C\$2),\$G14,INDIRECT(\$A\$2&\$D\$2),\$H14)"
.Value = .Value
'.NumberFormat = "DD-MM-YYYY"
End With
End With

With Worksheets("Intraday -EOD Stats")
With .Range("L14:L" & .Range("H" & .Rows.Count).End(xlUp).Row)
.Formula = "=SUMIFS(INDIRECT(\$A\$2&L\$1),INDIRECT(\$A\$2&\$B\$2),\$C14,INDIRECT(\$A\$2&\$C\$2),\$G14,INDIRECT(\$A\$2&\$D\$2),\$H14)"
.Value = .Value
'.NumberFormat = "DD-MM-YYYY"
End With
End With``````

### Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"

#### Herakles

##### Board Regular
So what is taking the time?

The writing the formula to the cells or the calculation?

Try turning automatic calculation off.

Application.Calculation = xlManual

and then on again at the end of the code

Application.Calculation = xlAutomatic

You will need to calculate the formulas before substituting the range with the result of the formula.

VBA Code:
``````Application.Calculation = xlManual

With Worksheets("Intraday -EOD Stats")
With .Range("I14:I" & .Range("H" & .Rows.Count).End(xlUp).Row)
.Formula = "=IF(\$H14<=\$D\$12,SUMIFS(INDIRECT(\$A\$6&\$B\$5),INDIRECT(\$A\$6&\$C\$5),\$C14,INDIRECT(\$A\$6&\$D\$5),\$H14))"
.Calculate
.Value = .Value
'.NumberFormat = "DD-MM-YYYY"
End With
End With

With Worksheets("Intraday -EOD Stats")
With .Range("K14:K" & .Range("H" & .Rows.Count).End(xlUp).Row)
.Formula = "=SUMIFS(INDIRECT(\$A\$2&K\$1),INDIRECT(\$A\$2&\$B\$2),\$C14,INDIRECT(\$A\$2&\$C\$2),\$G14,INDIRECT(\$A\$2&\$D\$2),\$H14)"
.Calculate
.Value = .Value
'.NumberFormat = "DD-MM-YYYY"
End With
End With

With Worksheets("Intraday -EOD Stats")
With .Range("L14:L" & .Range("H" & .Rows.Count).End(xlUp).Row)
.Formula = "=SUMIFS(INDIRECT(\$A\$2&L\$1),INDIRECT(\$A\$2&\$B\$2),\$C14,INDIRECT(\$A\$2&\$C\$2),\$G14,INDIRECT(\$A\$2&\$D\$2),\$H14)"
.Calculate
.Value = .Value
'.NumberFormat = "DD-MM-YYYY"
End With
End With

Application.Calculation = xlAutomatic``````

Replies
7
Views
81
Replies
4
Views
140
Replies
3
Views
259
Replies
0
Views
85
Replies
19
Views
184

Threads
1,133,828
Messages
5,661,157
Members
418,619
Latest member
ibruzzi

### Share this page ### We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

### Which adblocker are you using?    ### Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option. Go back

### Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com". Go back

### Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button. Go back

### Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button. Go back