VBA Resize named range

birchs92

New Member
Joined
Nov 1, 2007
Messages
44
I am attempting to re-size named range, struggling to find the correct syntax, todate I have the below...any suggestions !!!

Sub ResizeRange()
Dim Nm As Name
For Each Nm In ThisWorkbook.Names
If Nm.Name Like "*d*" And Not Nm.Name Like "*!*" Then
Nm.Resize(Nm.Rows.Count + 1, Nm.Columns.Count).Resize = "Nm"
End If
Next Nm
End Sub

Many Thanks
Simon
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
Perhaps

Code:
Range(Nm.Name).Resize(Range(Nm.Name).Rows.Count + 1, Range(Nm.Name).Columns.Count).Resize.Name = "Nm"
 
Upvote 0
or

ActiveWorkbook.Names(nm.name).RefersToRange.resize(Names(nm.name).RefersToRange.Rows.count+1,Names(nm.name).RefersToRange.Columns.Count)
 
Last edited:
Upvote 0
VoG Thanks

CharlesChuckieCharles Thanks


VoG

I have used:

Range(Nm.Name).Resize(5000, Range(Nm.Name).Columns.Count).Resize.Name = Nm.Name

When I used 'Range(Nm.Name).Rows.Count' just when down to 65535 (max possible row), how could I have used last non-blank cell ?

Many Thanks
Simon
 
Upvote 0
Perhaps like this

Code:
LR = Cells.Find(What:="*", SearchDirection:=xlPrevious, SearchOrder:=xlByRows).Row
Range(Nm.Name).Resize(LR, Range(Nm.Name).Columns.Count).Resize.Name = Nm.Name
 
Upvote 0

Forum statistics

Threads
1,224,617
Messages
6,179,914
Members
452,949
Latest member
beartooth91

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