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
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
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
 
Upvote 0
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
 
Upvote 0

Forum statistics

Threads
1,214,635
Messages
6,120,660
Members
448,975
Latest member
sweeberry

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
Back
Top