Compile Error

Jamm_027

Board Regular
Joined
Sep 10, 2007
Messages
249
Here is a portion of my code that inserts a formula for me.

Code:
With Range("A2", Cells(Cells.Rows.Count, 1).End(xlUp))
      .Offset(, 12).FormulaR1C1 = ("=COUNTIF(R1C1:R[-1]C1,R[-1]C[-12])>180")
End With

Works perfectly but now I want to make one small change. Instead of always being greater than "180". I need it to be greater than the value found on sheet2 in cell H2. I tried this but got a compile error....

Code:
With Range("A2", Cells(Cells.Rows.Count, 1).End(xlUp))
      .Offset(, 12).FormulaR1C1 = ("=COUNTIF(R1C1:R[-1]C1,R[-1]C[-12])>sheets("Sheet2").Range("H2").Value)
End With

thanks,

jamm
 

Some videos you may like

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number

Richard Schollar

MrExcel MVP
Joined
Apr 19, 2005
Messages
23,707
Hi Jamm

Try this:

Code:
With Range("A2", Cells(Cells.Rows.Count, 1).End(xlUp))
      .Offset(, 12).FormulaR1C1 = "=COUNTIF(R1C1:R[-1]C1,R[-1]C[-12])>" & sheets("Sheet2").Range("H2").Value
End With
 

Watch MrExcel Video

Forum statistics

Threads
1,122,481
Messages
5,596,395
Members
414,063
Latest member
N_Bates

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
Top