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

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
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,221,418
Messages
6,159,791
Members
451,589
Latest member
Harold14

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