Solved

Dynamic number of columns where value is greatert than 0

Posted on 2014-02-22
19
193 Views
Last Modified: 2014-02-22
Hi,
I'm trying to name a dynamic range using Offset.

=OFFSET(Cumulative!$C$4,0,0,COUNTA(Cumulative!$C4:$BB4),COUNTA(Cumulative!$C$4:$BB$4))

When I test the range the "dancing ants" cover the wrong area so I've obviously not grasped the concept of the Offset function.

I also cannot get it to work at all if I add the ">0"

What I'm trying to achieve is to have the named range expand to cells that have a value greater than 0 in row 4 from column C to column BB.

If I can get my head around this, I can alter the formula for more ranges and build a dynamic chart.

I have added a flat file so you can see what I'm trying  to work with.

As always your time is appreciated
Book1.xlsx
0
Comment
Question by:Stephen Byrom
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 11
  • 8
19 Comments
 
LVL 1

Author Comment

by:Stephen Byrom
ID: 39879201
Managed to get it to show the correct row now, but cannot fathom how to only expand to include cells greater than 0.

=OFFSET(Cumulative!$C$4,0,0,COUNTA(Cumulative!$C4:$C4),COUNTA(Cumulative!$C$4:$BB$4))
0
 
LVL 30

Expert Comment

by:gowflow
ID: 39879229
try this

=Sheet1!$C$4&":"&(CELL("address",INDEX(Sheet1!4:4,MATCH(0,Sheet1!4:4,0)-1)))

Open in new window


gowflow
0
 
LVL 1

Author Comment

by:Stephen Byrom
ID: 39879258
Hmmmm,
"try this" ..... where?
In a cell, or in the offset formula?
I tried in the offset formula but couldn't get it to show the correct data.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Author Comment

by:Stephen Byrom
ID: 39879270
I also tried it in the Name Manager and changed "Sheet1! to the correct name (Cumulative), but still no joy.
:(
0
 
LVL 30

Expert Comment

by:gowflow
ID: 39879401
what do you need to achieve why a named range ? I am good in VBA but these formulas thing is not my cup of tea !!
gowflow
0
 
LVL 30

Expert Comment

by:gowflow
ID: 39879402
where did you had first your offset formula ? in a named range ?
gowflow
0
 
LVL 1

Author Comment

by:Stephen Byrom
ID: 39879408
Yes.
The named range is

=OFFSET(Cumulative!$C$4,0,0,COUNTA(Cumulative!$C4:$C4),COUNTA(Cumulative!$C$4:$BB$4))

C4 always has a value greater than 0, but the columns grow as weeks are added, so I am trying to get the named range to expand to only cells in row 4 where the value is greater than 0
0
 
LVL 1

Author Comment

by:Stephen Byrom
ID: 39879413
I was thinking that maybe I could put a formula in an unused cell to return the cell address of the last cell in row 4 where the value is greater than 0 and refer to that in the named range "Offset" clause, but I can't get it to work.
0
 
LVL 30

Expert Comment

by:gowflow
ID: 39879498
ok if this is what you want then do this
=CELL("address",INDEX(Sheet1!4:4,MATCH(0,Sheet1!4:4,0)-1))

this will give you the last cell that contain non zero in row 4 starting from C4

gowflow
0
 
LVL 1

Author Comment

by:Stephen Byrom
ID: 39879515
Thanks,
I have entered that formula into an empty cell ( T1 ), and tried to refer to that cell in the offset formula of the named range,
=OFFSET(Sheet1!$C$4,0,0,COUNTA(Sheet1!$C:$C),COUNTA(Sheet1!$C$4 & ":T1 &"))

But I can't seem to refer to the cell address that T1 shows, (incidently currently I4)
0
 
LVL 30

Expert Comment

by:gowflow
ID: 39879518
pls post what you did as the file you posted did not have the offset formula so I was lost in what your trying to achieve. I usually solve things quickly !!!
gowflow
0
 
LVL 1

Author Comment

by:Stephen Byrom
ID: 39879531
Ok,
Thanks for your time.
I have attached the workbook
WorkInProg.xlsm
WorkInProg.xlsm
0
 
LVL 1

Author Comment

by:Stephen Byrom
ID: 39879542
Sorry I forgot it was protected. I have added an unprotected one
0
 
LVL 30

Expert Comment

by:gowflow
ID: 39879549
ok fine you posted that file but where is the OFFSET ???
what are you trying to achieve ? and why ? pls explain in plain English I am getting grrrrr

gowflow
0
 
LVL 1

Author Comment

by:Stephen Byrom
ID: 39879569
Hmmm.
I'm trying to do what I said earlier at http://www.experts-exchange.com/Software/Office_Productivity/Office_Suites/MS_Office/Excel/Q_28371615.html#a39879408.
The Offset is in the name manager? And its called Total509Builds?
0
 
LVL 1

Author Comment

by:Stephen Byrom
ID: 39879805
I now have this as the named range...
=OFFSET(Toyota!$C$4,0,(Toyota!T1),COUNTA(Toyota!$C4:$C4),COUNTA(Toyota!$C$4:$BB$4))

on the sheet ("Toyota") at cell T1, is the formula to get the cell address of the last cell in row 4 which is greater than 0.... "=CELL("address",INDEX(4:4,MATCH(0,4:4,0)-1))" , which returns the value $I$4.

I still can't get the offset range to show C4 to the variable cell address value of T1
0
 
LVL 30

Accepted Solution

by:
gowflow earned 500 total points
ID: 39879836
Here it is, I finally got it !!!
=Toyota!$C$4:INDEX(Toyota!$4:$4,,MATCH(0,Toyota!$4:$4,0)-1)

I create it in your last file and updated both
Total509Builds  I put its SUM in Cell G1
Total519Builds  I put its SUM in Cell H1

Just put any value in any 0 column in row 4 or row 21 and see how it automatically update G1 and H1.

Enjoy
gowflow
WorkInProg.xlsm
0
 
LVL 1

Author Closing Comment

by:Stephen Byrom
ID: 39879839
Thanks for your time.
0
 
LVL 30

Expert Comment

by:gowflow
ID: 39879861
Tks glad we got this one sorted out as frankly I am not into formulas at all and feel I did a breakthrough, I thank you for this !!! wow

gowflow
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Workbook link problems after copying tabs to a new workbook? David Miller (dlmille) Intro Have you either copied sheets to a new workbook, and after having saved and opened that workbook, you find that there are links back to the original sou…
How to get Spreadsheet Compare 2016 working with the 64 bit version of Office 2016
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question