#### K0st4din

##### Active Member
Hello,
please someone for help with this macro.
I wrote it manually, but when I open Alt + F11, I get some completely different formula from what I use.
What I'm trying to do is the following:
in the active worksheet from cell O2 to the end (because I do not know where the end will be)
I want to put this formula from cell "O2" and manually - pull down to the end
 =COUNTIFS(\$G\$2:\$G2; \$G2;\$J\$2:\$J2; \$J2) - in O2 =COUNTIFS(\$G\$2:\$G3; \$G3;\$J\$2:\$J3; \$J3) - in O3 =COUNTIFS(\$G\$2:\$G4; \$G4;\$J\$2:\$J4; \$J4) - in O4

<tbody>
</tbody>
to the end
When I started to write it manually, the macro itself showed me a completely different formula and I do not know how to do it
Code:
``````Sub Two_mounths()

Range("O2").Select
ActiveCell.FormulaR1C1 = "=COUNTIFS(RC7:RC7,RC7,R2C10:RC10,RC10)" 'this line
Range("O2").Select
Selection.AutoFill Destination:=Range("O2:O1231")
Range("O2:O1231").Select
Range("O1").Select
ActiveWorkbook.Save
Range("O1").Select
End Sub``````

### Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
Assuming that you can use column G to find where the end of the data is, try this:
Code:
``````Sub Two_months()

Dim lr As Long

'   Find last row with data in column G
lr = Cells(Rows.Count, "G").End(xlUp).Row

'   Populate formula for all rows
Range("O2:O" & lr).FormulaR1C1 = "=COUNTIFS(R2C7:RC7,RC7,R2C10:RC10,RC10)"

'   Save workbook
Activeworkbook.Save

End Sub``````

Thank you so much.
I wish all the best.

You are welcome.

Replies
3
Views
141
Replies
6
Views
315
Replies
3
Views
236
Replies
12
Views
497
Replies
4
Views
321

1,214,262
Messages
6,118,550
Members
448,835
Latest member
Profast123

### 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.

### Which adblocker are you using?

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

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