I'm trying to create a small table that you can double click on any cell and filter a second table based on the values in row 1 (AYEAR) and column B (AMONTH) to return the breakdown of the total value from my original table. How do I express this using R1C1 reference style?
ACLICK = Activecell.Address
AMONTH = RC2.Value
AYEAR = R1C.Value
What am I doing wrong?
CodePudding user response:
It needs to always look at row 1 for AYEAR and column B for AMONTH no matter which cell I'm double clicking in... EG: If I double click in J9 it needs to look at J1 for AYEAR and B9 for AMONTH
Simply:
AMONTH = Range("B" & ActiveCell.Row).Value ' or Cells(ActiveCell.Row, "B")
AYEAR = Cells(1, ActiveCell.Column).Value
Original answer:
IIUC, you're looking for Offset
, and there's no need to use .Address
or even think about R1C1 notation.
AMONTH = ActiveCell.Offset(,1).Value
AYEAR = ActiveCell.Offeset(1).Value