Dynamic named ranges

Bernieg

Board Regular
Joined
Jan 1, 2009
Messages
147
Office Version
  1. 365
Platform
  1. Windows
Hi

I'm trying to set up a named range called " chart_op_data "
the code below works fine counting rows & 12 columns.

However there is often less columns then 12 , 12 being the maximum
data is used for charts

how do i count columns as well....i'm sure theres some one who knows

Bernie

' Chart option data
ActiveWorkbook.Names.Add Name:="chart_op_data", RefersToR1C1:= _
"=OFFSET('Column Chart, Options Data'!R1C1,0,0,COUNTA('Column Chart, Options Data'!C1)+1,12)"
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
added as you sugested but iget 3 columns extra

ActiveWorkbook.Names.Add Name:="chart_op_data", RefersToR1C1:= _
"=OFFSET('Column Chart, Options Data'!R1C1,0,0,COUNTA('Column Chart, Options Data'!C1)+1,COUNTA('Column Chart, Options Data'!R1))"

sure im doing somthing wrong

Bernie
 
Upvote 0
it does work i had 3 columns further to the left used for counting

sorry about that

is there a way to limit the column count to say up to 12 columns

Bernie
 
Upvote 0
Hi

Deleted the 3 columns to the left, but it still leaves me 1 column short

i.e 5 populated columns, but the range only covers 4

Bernie
 
Upvote 0
Hi

Deleted the 3 columns to the left, but it still leaves me 1 column short

i.e 5 populated columns, but the range only covers 4

Bernie

The range will have as many columns as there are non blank cells in row1 and always start at a1.
 
Upvote 0
Hi Arul

thanks for your help, your code is good the problem is a1 was empty
that was why i was 1 column short

once again thanks for your help & patiance.

Bernie
 
Upvote 0

Forum statistics

Threads
1,224,600
Messages
6,179,836
Members
452,947
Latest member
Gerry_F

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