Solved

Dynamic number of columns where value is greatert than 0

Posted on 2014-02-22
19
189 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
  • 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 29

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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
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 29

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 29

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 29

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 29

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 29

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 29

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 29

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

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

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

A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
Excel can be a tricky bit of software to get your head around. Whilst you’ll be able to eventually get to grips with the basic understanding of how to get by, there are a few Excel tips that not everybody will even know about let alone know how to d…
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

803 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