1

Simple question that is eluding me. I have an active row selected. I need to resize this range to add the next 22 rows using VBA. E.g. its currently highlighting row 100 only. I would now like to expand the selection to highlight row 100 through 122.

Thanks in advance.

RRP
  • 61
  • 1
  • 7
  • 1
    Please provide a little more context. Do you want to expand the selection so that a larger range is selected or do you want to assign the result to a range variable? If the former -- why? There is almost always a better way to interact with the spreadsheet than use `Select` and `Selection`. See [How to avoid using Select in Excel VBA](https://stackoverflow.com/q/10714251/4996248). – John Coleman Aug 30 '18 at 16:21
  • I would like to expand the selection. E.g. its currently highlighting row 100 only. I would now like to expand the selection to highlight row 100 through 122. – RRP Aug 30 '18 at 16:24
  • So you're saying you want to _resize_ the selection? Could you edit your question with a bit more detail please. – Darren Bartrup-Cook Aug 30 '18 at 16:25
  • Thanks. I updated my question. – RRP Aug 30 '18 at 16:27

2 Answers2

0

To extend the selection use:

Range(Selection, Selection.Offset(22)).Select

This will work, although it isn't a bad idea to find a way to avoid such selection-based code.

John Coleman
  • 51,337
  • 7
  • 54
  • 119
0
Selection.Resize(22).Select

Seems like the more straightforward method.

Dick Kusleika
  • 32,673
  • 4
  • 52
  • 73