How do I stop a formula from changing??

justme

Well-known Member
Joined
Aug 26, 2002
Messages
729
=COUNTIF($D$8:$D$120,1)

I have this formula in cell E1. I also have a macro which deletes rows that have blank cells. When I run the macro, the $D$120 keeps changing (reducing). How can I get the cell to ALWAYS remain the same? I want it to be absolute, not relative.

Thanks.[/b]
 
Range("h8").Select
ActiveCell.FormulaR1C1 = "=COUNTIF(R8C3:R120C3,g8)"

Here's another instance that is not working. When the macro runs the formula changes the ,g8 to ,'g8' and only returns a 0 value.

What is the work-around for this situation?
 
Upvote 0

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
The reason it's changing it to 'G8' is because you are using A1 notation for G8 and R1C1 notation for the rest of the formula.

What is the actual formula in A1 notation?

Code:
Range("h8").Formula = "=COUNTIF(C8:C120,G8)"
 
Upvote 0

Forum statistics

Threads
1,214,875
Messages
6,122,046
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