Having Problems understanding R1C1.

Guzzlr

Well-known Member
Joined
Apr 20, 2009
Messages
946
Office Version
  1. 2016
Platform
  1. Windows
Hello
I have from the recoreder:

VBA Code:
Set BurnDown = Sheets("BurnDown")
    Range("C2").Select
    ActiveCell.FormulaR1C1 = "=COUNTIF(ECD!C[5],BurnDown!RC[-1])"
    Range("C2").Select
    Selection.AutoFill Destination:=Range("C2:C81"), Type:=xlFillDefault
    Range("C2:C81").Select

What would this code be with out all the "select" stuff and not using R1C1 formatting?
Thanks for the help
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
Try
VBA Code:
Sheets("BurnDown").Range("C2:C81").FormulaR1C1 = "=COUNTIF(ECD!H:H,B2)"
The easiest way to find out what the formula is in A1 notation, is to look at the formula in the cell.
 
Upvote 0
Its is pretty much the same as waht fluff told you last week here: R1C1 ConuntA formula
Just apply it to multiple cells instead of one cell.
 
Upvote 0
Sheets("BurnDown").Range("C2:C81").FormulaR1C1 = "=COUNTIF(ECD!H:H,B2)"

I believe that should be:

Range("C2:C81").Formula = "=COUNTIF(ECD!H:H, 'BurnDown'!B2)"
or
ActiveSheet.Range("C2:C81").Formula = "=COUNTIF(ECD!H:H, 'BurnDown'!B2)"

1. In this code snippet, there is no BurnDown.Select. (Contrast with the code in the discussion cited by Joe4.)
Perhaps an unintended omission here. But without it, Range("C2:C18") is in ActiveSheet, which might not be BurnDown.

2. With A1 references, we must use Formula. FormulaR1C1 raises an error.

3. We must reference the BurnDown worksheet explicitly in the COUNTIF formula.
Otherwise, B2 refers to ActiveSheet.B2, which might not be BurnDown.B2, as noted in #1.

4. I use 'BurnDown'!B2 instead of simply BurnDown!B2 to demonstrate the necessary syntax
(single quotes) if the sheet name had included non-alphanumeric characters, notably spaces.
In this particular example, BurnDown!B2 (without single quotes) would work, too.

PS.... Arguably, one difference between this form and using AutoFill might be the format of the cells. I have not bothered to check, though. Someone else might. In other words, what if the format of C2 is different from C3:C18?
 
Last edited:
Upvote 0
Its is pretty much the same as waht fluff told you last week here: R1C1 ConuntA formula
Just apply it to multiple cells instead of one cell.
So i tried playing around with it for some time, and it kept error on me, no matter what different
scenarios I tried...so in a fit of rage, I asked you guys...
 
Upvote 0
Glad we could help & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,979
Messages
6,122,552
Members
449,088
Latest member
davidcom

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