Expanding a named range

davey4444

Board Regular
Joined
Nov 16, 2010
Messages
97
I have data coming into my sheet from an Access file into columns b:l which automatically get covered by a named range which changes according to the size of the data coming in.

What I'd like to create is a named range which includes this original range as well as columns a and m:p. Is this possible using Offset at all?

On top of this my data from Access comes into row 2 and I'd like the named range to cover row 1 too.

Thanks in advance.
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
I have data coming into my sheet from an Access file into columns b:l which automatically get covered by a named range which changes according to the size of the data coming in.

What I'd like to create is a named range which includes this original range as well as columns a and m:p. Is this possible using Offset at all?

On top of this my data from Access comes into row 2 and I'd like the named range to cover row 1 too.

Thanks in advance.
Care to post the current definition you have?
 
Upvote 0
Here's an example


Code:
Sub Foo()
Dim NewRng As String
Dim rc as long
With Range("InnerRange")   'Testing your existing InnerRange Name for the current Number of rows
    rc = .Rows.Count
End With
NewRng = Range("InnerRange").Offset(-1, -1).Resize(rc + 1, 5).Address  'Get Address of desired expanded OutterRange
Range("OutterRange").Name.Delete    'Remove any existing reference to the OutterRange should it exist
ActiveWorkbook.Names.Add Name:="OutterRange", _
        RefersTo:=Sheets("Sheet1").Range(NewRng)   'Add/Create your New OutterRange RangeName
End Sub
 
Upvote 0
Thanks Jim, your code worked great. The only hiccup was where it checks to see if the name previously exists where I had an "object not defined" error but that was easily overcome.
 
Upvote 0

Forum statistics

Threads
1,214,384
Messages
6,119,201
Members
448,874
Latest member
Lancelots

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