Resize range into a range specified in a cell

luzikedy

New Member
Joined
May 23, 2014
Messages
45
Hi,

Here is what I did by combining few things I found on the forums.


Sub Resize_Named_Range()


Dim wb As Workbook
Dim nr As Name
Dim rng As range
Set rng = Sheets("data").range("a1") "This cell has cell reference in it - sheet1!$A$1:$A$10"
Set wb = ActiveWorkbook
Set nr = wb.Names.Item("Produkcja_AD")
nr.RefersTo = rng.Text
End Sub

I almost works, the only but is that instead resizing the range into something like this:

=sheet1!$A$1:$A$10


I get "" outside

="sheet1!$A$1:$A$10"


Thx for help with getting rid of "" in the result.
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
Could you be more specific about what you're trying to do?
 
Upvote 0
I am trying to change one of my named ranges called "Produkcja_AD"

in Sheets("data").range("a1") - I have a result of a formula that calculates the range I want to obtain and it results is:

sheet1!$A$1:$A$10

which I want to be the new range of namedrange "Produkcja_AD"

I hope this is more clear.
 
Upvote 0
Code:
Sub F()
    Range(Sheets("data").Range("A1").Text).Name = "Produkcja_AD"
    '// Just test
    MsgBox WorksheetFunction.Count(Range("Produkcja_AD"))
End Sub
 
Upvote 0
You're welcome!
hi.gif
 
Upvote 0

Forum statistics

Threads
1,223,229
Messages
6,170,881
Members
452,364
Latest member
springate

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