0

I am trying to activate the range 4 across and 'n' down from the current active cell. I am new to VBA and programming as a whole.

I have tried putting each "ActiveCell.Offset(0, 0)" in its own parentheses and without. It also works with the first as "ActiveCell.Offset(0, 1)" but I want the upper left cell in the activated range to be the original ActiveCell

     Range(ActiveCell.Offset(0, 0), ActiveCell.Offset(n, 4)).Activate

When I put ActiveCell.Offset(0, 0) in their own parentheses I get an error message "method 'range' of object '_global' failed". Ran without the parentheses it just does nothing at all without an error.

KKulhanek
  • 7
  • 2
  • I think you want `.Select` on the end instead. And remove `.Offset(0,0)` – Scott Craner Jun 03 '19 at 22:30
  • or just use `Resize`: `ActiveCell.Resize(n,4).select` – Scott Craner Jun 03 '19 at 22:39
  • as mentioned by @chris neilsen in his answer try to avoid using select/activate entirely. What is it you want to do with the range? Most likely there's a way to do it without selection or activating it first. – Nick Jun 04 '19 at 04:43

1 Answers1

2

From the documentation

Range.Activate method

Activates a single cell, which must be inside the current selection. To select a range of cells, use the Select method.

So, your code could be

Range(ActiveCell, ActiveCell.Offset(n, 4)).Select

That said, consider not using Activate/Select at all. See here for how.

Community
  • 1
  • 1
chris neilsen
  • 52,446
  • 10
  • 84
  • 123