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
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
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
 
Upvote 0

Forum statistics

Threads
1,214,875
Messages
6,122,040
Members
449,063
Latest member
ak94

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