VBA not posting down the column

ianawwalker

New Member
Joined
Feb 16, 2023
Messages
15
Office Version
  1. 365
  2. 2021
Platform
  1. Windows
Hello,

I have this formula that I want to have filled down to the last row in column A, which could go down 20-30K rows. The VBA I am currently using is only pasting within row 2 of each of the columns and i can't figure out why. Any help would be greatly appreciated.

With Sheets("US_Combine")

.Range("C2:C" & Cells(Rows.Count, 3).End(xlUp).Row).Formula2R1C1 = _
"=SUM(COUNTIFS(US_Exceptions!C1,US_Combine!RC1,US_Exceptions!C2,INDEX(US_Codes!R2C[-1]:R11C[-1],0)))"
.Range("D2:D" & Cells(Rows.Count, 3).End(xlUp).Row).Formula2R1C1 = _
"=SUM(COUNTIFS(US_Exceptions!C1,US_Combine!RC1,US_Exceptions!C2,INDEX(US_Codes!R2C[-1]:R11C[-1],0)))"
.Range("E2:E" & Cells(Rows.Count, 3).End(xlUp).Row).Formula2R1C1 = _
"=SUM(COUNTIFS(US_Exceptions!C1,US_Combine!RC1,US_Exceptions!C2,INDEX(US_Codes!R2C[-1]:R11C[-1],0)))"
.Range("F2:F" & Cells(Rows.Count, 3).End(xlUp).Row).Formula2R1C1 = _
"=SUM(COUNTIFS(US_Exceptions!C1,US_Combine!RC1,US_Exceptions!C2,INDEX(US_Codes!R2C[-1]:R11C[-1],0)))"

End With

Thank you,

Ian
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
If it is to the last cell in column A the red 3 should be a 1.
Rich (BB code):
.Range("C2:C" & Cells(Rows.Count, 3).End(xlUp).Row)
there should also be a dot in front of Cells
Rich (BB code):
.Range("C2:C" & .Cells(Rows.Count, 1).End(xlUp).Row)
 
Last edited:
Upvote 0
Solution
that worked great, but took around 3 min to go into all 4 of the columns. do you know a way to speed it up at all?

thank you!!
 
Upvote 0
Only turning your screenupdating off and setting your calculation to manual while entering the formula (remember to set the calculation back to automatic after the formulas have been entered)
 
Upvote 0
You're welcome

VBA Code:
    With Application
        .Calculation = xlCalculationManual
        .ScreenUpdating = False
    End With

    With Sheets("US_Combine")

        .Range("C2:C" & .Cells(Rows.Count, 1).End(xlUp).Row).Formula2R1C1 = _
                    "=SUM(COUNTIFS(US_Exceptions!C1,US_Combine!RC1,US_Exceptions!C2,INDEX(US_Codes!R2C[-1]:R11C[-1],0)))"
        .Range("D2:D" & .Cells(Rows.Count, 1).End(xlUp).Row).Formula2R1C1 = _
                    "=SUM(COUNTIFS(US_Exceptions!C1,US_Combine!RC1,US_Exceptions!C2,INDEX(US_Codes!R2C[-1]:R11C[-1],0)))"
        .Range("E2:E" & .Cells(Rows.Count, 1).End(xlUp).Row).Formula2R1C1 = _
                    "=SUM(COUNTIFS(US_Exceptions!C1,US_Combine!RC1,US_Exceptions!C2,INDEX(US_Codes!R2C[-1]:R11C[-1],0)))"
        .Range("F2:F" & .Cells(Rows.Count, 1).End(xlUp).Row).Formula2R1C1 = _
                    "=SUM(COUNTIFS(US_Exceptions!C1,US_Combine!RC1,US_Exceptions!C2,INDEX(US_Codes!R2C[-1]:R11C[-1],0)))"

    End With


    With Application
        .Calculation = xlCalculationAutomatic
        .ScreenUpdating = True
    End With
 
Upvote 0

Forum statistics

Threads
1,214,566
Messages
6,120,257
Members
448,952
Latest member
kjurney

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