VBA - Custom defined names based on range in cell value

pina1990

New Member
Joined
Sep 16, 2022
Messages
2
Office Version
  1. 365
Platform
  1. Windows
Looking for a bit of help from a VBA noob here.

I'm trying to write a vba which will define a name of a table based on the range which is defined as text in a cell (this is to let me easily control the range of the table array based on its content).

The code I've been using is:

VBA Code:
Range("B8:E40").Select
    ActiveWorkbook.Names.Add Name:="Beam_Summary1", RefersToR1C1:= _
        "='Beam Summary'!R8C2:R40C5"

I've got Cell P15 on worksheet 'Beam Summary' which defines the range of the table array and want to be able to introduce that instead of the range select and "='Beam Summary'!R8C2:R40C5" in the code above. I've tried defining a variable and using that but not really having any luck. Any ideas?
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
Welcome to the Forum!

If 'Beam Summary'!P15 contains: B8:E40, then:
VBA Code:
Range(Worksheets("Beam Summary").Range("P15").Value).Name = "Beam_Summary1"
will create BeamSummary1: ='Beam Summary'!$B$8:$E$40
 
Upvote 0

Forum statistics

Threads
1,224,828
Messages
6,181,209
Members
453,022
Latest member
RobertV1609

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