Offsetting Column Ranges - How?

lynxbci

Board Regular
Joined
Sep 22, 2004
Messages
201
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
Hi
Scenario: There is a column range predefined lets say $B:$G (6 columns)

Question 1The user enters a number in a cell (A1) and i want to offset this selection by that many columns.
eg If the users enters 3 in A1 then the range would now be $E:$J (3 columns to the right, still 6 columns wide).

How is this done?

Question 2If the user enters a number in a cell (A2) then this will redefine the columns in the range.
eg If the user enters a 4 in A2 then the range would now be $E:$H (3 cols right and now 4 cols wide).

How is this done?

I am aware of how to set ranges with tables, but don't want to use rows at all, only column references, and it is proving difficult.

Many thanks in advance
 

Some videos you may like

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.

lynxbci

Board Regular
Joined
Sep 22, 2004
Messages
201
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
In VBA, not fussed about keeping or naming the range, just knowing what the new range is and then using it for a lookup reference.

thanks
 

Andrew Poulsom

MrExcel MVP
Joined
Jul 21, 2002
Messages
73,092
Like this?

Code:
Sub Test()
    MsgBox Range("B:G").Offset(, Range("A1").Value).Address
    MsgBox Range("B:G").Offset(, Range("A1").Value).Resize(, Range("A2").Value).Address
End Sub
 

Watch MrExcel Video

Forum statistics

Threads
1,123,057
Messages
5,599,545
Members
414,316
Latest member
ExcelLee

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
Top