Making a table Macro More efficient

cimajc17

New Member
Joined
Jun 10, 2015
Messages
15
Hey everyone
I'm using this code to make a table for a graph to update by selection of data but I'm using a very inefficient method to do it. it works but I am wondering if there is a better way.

Range("B22").Select
ActiveCell.FormulaR1C1 = _
"=(COUNTIFS('Hidden graph sheet'!R2C46:R" & lastRowHiddengraphSheet2 & "C46,3,'Hidden graph sheet'!R2C45:R" & lastRowHiddengraphSheet2 & "C45,1)/COUNTIF('Hidden graph sheet'!R2C42:R" & lastRowHiddengraphSheet2 & "C42,1))*100"
Range("C22").Select
ActiveCell.FormulaR1C1 = _
"=(COUNTIFS('Hidden graph sheet'!R2C46:R" & lastRowHiddengraphSheet2 & "C46,2,'Hidden graph sheet'!R2C45:R" & lastRowHiddengraphSheet2 & "C45,1)/COUNTIF('Hidden graph sheet'!R2C42:R" & lastRowHiddengraphSheet2 & "C42,1))*100"
Range("D22").Select
ActiveCell.FormulaR1C1 = _
"=(COUNTIFS('Hidden graph sheet'!R2C46:R" & lastRowHiddengraphSheet2 & "C46,1,'Hidden graph sheet'!R2C45:R" & lastRowHiddengraphSheet2 & "C45,1)/COUNTIF('Hidden graph sheet'!R2C42:R" & lastRowHiddengraphSheet2 & "C42,1))*100"
Range("E22").Select
ActiveCell.FormulaR1C1 = _
"=(COUNTIFS('Hidden graph sheet'!R2C46:R" & lastRowHiddengraphSheet2 & "C46,4,'Hidden graph sheet'!R2C45:R" & lastRowHiddengraphSheet2 & "C45,1)/COUNTIF('Hidden graph sheet'!R2C42:R" & lastRowHiddengraphSheet2 & "C42,1))*100"
Range("B23").Select
ActiveCell.FormulaR1C1 = _
"=(COUNTIFS('Hidden graph sheet'!R2C46:R" & lastRowHiddengraphSheet2 & "C46,3,'Hidden graph sheet'!R2C45:R" & lastRowHiddengraphSheet2 & "C45,2)/COUNTIF('Hidden graph sheet'!R2C42:R" & lastRowHiddengraphSheet2 & "C42,1))*100"
Range("C23").Select
ActiveCell.FormulaR1C1 = _
"=(COUNTIFS('Hidden graph sheet'!R2C46:R" & lastRowHiddengraphSheet2 & "C46,2,'Hidden graph sheet'!R2C45:R" & lastRowHiddengraphSheet2 & "C45,2)/COUNTIF('Hidden graph sheet'!R2C42:R" & lastRowHiddengraphSheet2 & "C42,1))*100"
Range("D23").Select
ActiveCell.FormulaR1C1 = _
"=(COUNTIFS('Hidden graph sheet'!R2C46:R" & lastRowHiddengraphSheet2 & "C46,1,'Hidden graph sheet'!R2C45:R" & lastRowHiddengraphSheet2 & "C45,2)/COUNTIF('Hidden graph sheet'!R2C42:R" & lastRowHiddengraphSheet2 & "C42,1))*100"
Range("E23").Select
ActiveCell.FormulaR1C1 = _
"=(COUNTIFS('Hidden graph sheet'!R2C46:R" & lastRowHiddengraphSheet2 & "C46,4,'Hidden graph sheet'!R2C45:R" & lastRowHiddengraphSheet2 & "C45,2)/COUNTIF('Hidden graph sheet'!R2C42:R" & lastRowHiddengraphSheet2 & "C42,1))*100"


I am basically writing a slightly changed formula for each part of the table but i select a different range each time. Thanks
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.

Forum statistics

Threads
1,223,236
Messages
6,170,906
Members
452,366
Latest member
TePunaBloke

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
Back
Top