none
Shifting a range to the right RRS feed

  • Question

  • Hello,

    I have a range defined in code. Let's say it is a 2 column range that is columns 3 and 4, so the range is 2 cells/columns wide. How does one shift that range to the right by 3, so that the range is then columns 6 and 7?

    Many thanks.

    Keith


    R K Howard

    Sunday, October 28, 2018 7:50 PM

Answers

All replies

  • Let's say you have a variable rng of type Range. The range shifted 3 columns to the right is

    rng.Offset(ColumnOffset:=3)


    Regards, Hans Vogelaar (http://www.eileenslounge.com)

    Sunday, October 28, 2018 8:52 PM
  • Hello Hans,

    Your answer shows how to refer to a range that is 3 columns to the right (I had already been using that technique), but it does not reassign the current range variable to such value, which is what I am trying to do.

    Many thanks.

    Keith


    R K Howard

    Monday, October 29, 2018 4:21 PM
  • Set rng = rng.Offset(ColumnOffset:=3)

    Regards, Hans Vogelaar (http://www.eileenslounge.com)

    Monday, October 29, 2018 4:45 PM