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

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
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,224,597
Messages
6,179,812
Members
452,945
Latest member
Bib195

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