MrExcel Message Board

Go Back   MrExcel Message Board > Question Forums > Excel Questions

Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only.

Reply
 
Thread Tools Display Modes
Old Apr 16th, 2002, 02:29 PM   #1
Todd K
New Member
 
Join Date: Feb 2002
Posts: 31
Default

I have a worksheet for which I want to select an area which is 11 columns wide by a variable # rows. This variable # of rows depends on whether there is data - the first row that lacks data in column k should be omitted from my selection. The first or anchor cell at top left of selection is a13. The longest the list could be is to row 300.

My approach has been to attempt to define a name for this area - using this formula:
=offset(indirect("a13"),0,0,max(1,count(indirect("k13:k300"))),11).

This only selects the first row...what am I missing?

I then want to sort this list by a column, paste all this on a new page, and insert subtotals by the sort key. I think I can get most of that, but any suggestions would be most helpful!
Todd K is offline   Reply With Quote
Old Apr 16th, 2002, 02:37 PM   #2
Al Chara
MrExcel MVP
 
Join Date: Feb 2002
Location: Monterrey, Mexico
Posts: 1,433
Default

Ever thought about using VBA?
Al Chara is offline   Reply With Quote
Old Apr 16th, 2002, 02:49 PM   #3
Aladin Akyurek
MrExcel MVP
 
Aladin Akyurek's Avatar
 
Join Date: Feb 2002
Location: The Hague
Posts: 50,317
Default

Quote:
On 2002-04-16 13:29, Todd K wrote:
I have a worksheet for which I want to select an area which is 11 columns wide by a variable # rows. This variable # of rows depends on whether there is data - the first row that lacks data in column k should be omitted from my selection. The first or anchor cell at top left of selection is a13. The longest the list could be is to row 300.

My approach has been to attempt to define a name for this area - using this formula:
=offset(indirect("a13"),0,0,max(1,count(indirect("k13:k300"))),11).

This only selects the first row...what am I missing?

I then want to sort this list by a column, paste all this on a new page, and insert subtotals by the sort key. I think I can get most of that, but any suggestions would be most helpful!
Todd,

I'll assume that the worksheet is named Data in what follows. Adjust to suit.

Activate Insert|Name|Define.
Enter Drecs as name in the Names in Workbook box.
Enter as formula in the Refers to box:

=MATCH(9.99999999999999E+307,Data!$K:$K)

Activate Add. (Don't leave yet the Define Name window.)

Enter DRange as name in the Names in Workbook box.
Enter as formula in the Refers to box:

=OFFSET(Data!$A$13,0,0,Drecs-ROW(Data!$A$13)+1,11)

Activate OK.

Now you can use Drange in formulas whenever appropriate to do so.

Aladin
Aladin Akyurek is offline   Reply With Quote
Old Apr 16th, 2002, 02:54 PM   #4
Yogi Anand
MrExcel MVP
 
Join Date: Mar 2002
Location: Michigan USA
Posts: 11,452
Default

Quote:
On 2002-04-16 13:29, Todd K wrote:
I have a worksheet for which I want to select an area which is 11 columns wide by a variable # rows. This variable # of rows depends on whether there is data - the first row that lacks data in column k should be omitted from my selection. The first or anchor cell at top left of selection is a13. The longest the list could be is to row 300.

My approach has been to attempt to define a name for this area - using this formula:
=offset(indirect("a13"),0,0,max(1,count(indirect("k13:k300"))),11).

This only selects the first row...what am I missing?

I then want to sort this list by a column, paste all this on a new page, and insert subtotals by the sort key. I think I can get most of that, but any suggestions would be most helpful!
Hi ToddK:
I think you are doing fine. I checked your setup and it works. If you are trying to select your range from your formula

=OFFSET(INDIRECT("a13"),0,0,MAX(1,COUNT(INDIRECT("k13:k300"))),11)

and you are selecting cell A13 only -- that's because you have hit a home run but you are on third base and have not completed the trip yet.

After establishing your formula, this is what still needs to be done ...

1) goto INSERT|NAME|DEFINE
key-in TODDK (or whatever range name you want to assign in Names in Workbook

2) in refers to, key in your formula

=OFFSET(INDIRECT("a13"),0,0,MAX(1,COUNT(INDIRECT("k13:k300"))),11)

3) OK

now we are allset having established the range name that the formula will use

Now if you go check with EDIT|GOTO|ToddK, you will see your selected range highlited

HTH

__________________
Regards!

Yogi Anand, D.Eng, P.E.
Energy Efficient Building Network LLC
www.energyefficientbuild.com
Yogi Anand is offline   Reply With Quote
Old Apr 16th, 2002, 03:03 PM   #5
Al Chara
MrExcel MVP
 
Join Date: Feb 2002
Location: Monterrey, Mexico
Posts: 1,433
Default

Assuming that the value of A13 is I13 then the following formula should work:
=OFFSET(INDIRECT(Sheet1!$A$13),0,0,MAX(1,COUNT(Sheet1!$K$13:$K$300)),11)

It will select the rows I through S and the a certain amount of columns depending on the number of used cells in K13 through K300.
__________________
Kind regards,

Al Chara
Al Chara is offline   Reply With Quote
Old Apr 16th, 2002, 07:55 PM   #6
Todd K
New Member
 
Join Date: Feb 2002
Posts: 31
Default

Yogi and Al: Thanks for your input. Unfortunately, I still am unable to resolve the problems that I originally described, i.e., I still only get one row of data selected, even when there are 52 rows in the list. If you like, I can send you the workbook and maybe you will be able to troubleshoot what I am doing wrong, since I think this approach is still on the right track. Yes, Al, I am hoping to use some VBA to automate my tasks that I described in the original message, although I am certainly no wizard with VBA.

Aladin - you are my white knight! It worked like a charm - and a very different approach from the one I have been laboring with. Please tell me that you make a living dealing with Excel - it will please me to know that some smart organization/people pay you for your brilliance!
Todd K is offline   Reply With Quote
Old Apr 16th, 2002, 08:36 PM   #7
Yogi Anand
MrExcel MVP
 
Join Date: Mar 2002
Location: Michigan USA
Posts: 11,452
Default

Quote:
On 2002-04-16 18:55, Todd K wrote:
Yogi and Al: Thanks for your input. Unfortunately, I still am unable to resolve the problems that I originally described, i.e., I still only get one row of data selected, even when there are 52 rows in the list. If you like, I can send you the workbook and maybe you will be able to troubleshoot what I am doing wrong, since I think this approach is still on the right track. Yes, Al, I am hoping to use some VBA to automate my tasks that I described in the original message, although I am certainly no wizard with VBA.

Aladin - you are my white knight! It worked like a charm - and a very different approach from the one I have been laboring with. Please tell me that you make a living dealing with Excel - it will please me to know that some smart organization/people pay you for your brilliance!
Hi ToddK:
I don't know what you mean you still can select only one row even though there are 52 rows of data. I am able to select all rows starting from A13 all the way to K300 if I populate K13 to K300.
Did you INSERT|DEFINE|NAME ToddK as I suggested and then EDIT|GOTO ToddK!
All I can tell you I am able to select all the populated rows.
So, please post back what happened when you inserted a range name and then selected the range by going to EDIT|GOTO ?

__________________
Regards!

Yogi Anand, D.Eng, P.E.
Energy Efficient Building Network LLC
www.energyefficientbuild.com
Yogi Anand is offline   Reply With Quote
Old Apr 17th, 2002, 07:18 AM   #8
Todd K
New Member
 
Join Date: Feb 2002
Posts: 31
Default

Yogi:

I did exactly what you have indicated several times, but the only row which winds up selected is row 13, from columns A to K. It really has me stumped, cuz I too believe it should work, but it refuses to do so. Could there be an issue with the data type in column K? (I have text there...)
Todd K is offline   Reply With Quote
Old Apr 17th, 2002, 08:02 AM   #9
Todd K
New Member
 
Join Date: Feb 2002
Posts: 31
Default

Ah, I think I have figured out my problem. Can anyone help me twist these functions to deal with the fact that what I am really trying to do is limit the selection to the data that is in column B (which is text, not numbers) as opposed to the data in column K? Both approaches appear to work well when the data in K is numeric, but the function also allows the range to grow beyond the limits of where I want it because there are formulas in column K that appear to influence the depth of the selection, even when the formulas evaluate to zero. Column B, on the other hand, has text that will not go beyond the last and desired row...
Todd K is offline   Reply With Quote
Old Apr 17th, 2002, 08:28 AM   #10
Aladin Akyurek
MrExcel MVP
 
Aladin Akyurek's Avatar
 
Join Date: Feb 2002
Location: The Hague
Posts: 50,317
Default

Quote:
On 2002-04-17 07:02, Todd K wrote:
Ah, I think I have figured out my problem. Can anyone help me twist these functions to deal with the fact that what I am really trying to do is limit the selection to the data that is in column B (which is text, not numbers) as opposed to the data in column K? Both approaches appear to work well when the data in K is numeric, but the function also allows the range to grow beyond the limits of where I want it because there are formulas in column K that appear to influence the depth of the selection, even when the formulas evaluate to zero. Column B, on the other hand, has text that will not go beyond the last and desired row...
Just change my

=MATCH(9.99999999999999E+307,Data!$K:$K)

to either

=MATCH(REPT("z",50),Data!$B:$B)

or

=MATCH(REPT("z",50),Data!$B$1:$B$300) [ in order to exploit the limit you mentioned ]

Aladin
Aladin Akyurek is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT -4. The time now is 08:36 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
All contents Copyright 1998-2012 by MrExcel Consulting.
diabetic desserts recipes recipes Diabetic Soups Holiday Pizza Recipes Popcorn Recipes Recipes For Microwave Pasta Recipes Casserole Recipes Chili Recipes Curry Recipes Crockpot Recipes Apples Recipes Bread Recipes Vegetarian Recipes Vegetable recipes Desserts Recipes Appetizers Ethnic Recipes Meat Dishes Barbecue Recipes Sauces Recipes Marinade Recipes Low Fat Recipes Frugal Gourmet Kitchen Classics Recipes On The Grill Cook Books Seafood Recipes Cajun Recipes Breads Low Fat Low Fat Breads Bread Machine Recipes Yeast Breads Quick Breads Fat Free Vegetarian Salad Recipes Eggplant Recipes Radish Recipes Tomato Recipes Jalapeno Recipes Potato Recipes Lettuce Recipes Cabbage Recipes Beans Ambrosia Recipes Biscotti Recipes Desserts Low Fat Cookie Recipes Cheesecake Recipes Cake Recipes Pie Recipes Muffin Recipes Custard Recipes Best Appetizers Appetizers Low Fat Salsa Recipes Dip Recipes International Recipes Afghan Recipes Alaska Recipes French Recipes German Recipes Greek Recipes Italian Recipes Spanish Recipes Thai Recipes Korean Recipes Chinese Recipes Mexican Recipes Indian Recipes Beef Recipes Pork Pork & Ham Pork Butts Pork Chop Recipes Pork Ribs Rulled Pork Poultry Recipes Stews Recipes Ground Beef Barbecue Grill Barbecue Smoker All Purpose Sauce BBQ Sauce Barbecue Sauce Carolina BBQ Sauce Pickle Recipes Marinades Smoking Low Fat Appetizers & Dips Low Fat Breakfast Low Fat Cakes Low Fat Cheesecakes Low Fat Cookies Low Fat Desserts Low Fat Fish & Seafood Low Fat Meats Low Fat Pasta Low Fat Pies Low Fat Salads Low Fat Sandwiches Low Fat Sauces & Condiments Low Fat Sides Low Fat Soups Low Fat Vegetarian Baker's Dozen Taste of Home Recipe Book Bon Appetit Cookbook Blacktie Cookbook Buster Cook Book Cookbook USA Cook Book Cook Book Sara's Cookbook Sara's Cookbook Appetizers and Dips Poultry recipes Diabetic recipes Holiday recipes Miscellaneous recipes 110 recipes 1986 Usenet cookbook 2900 recipes Cyberrealm recipes Great sysops of world Specialty recipes Ceideburg recipes Cheese recipes Chili recipes Fruits recipes Garlic recipes Great chefs of NY Londontowne recipes Raisins recipes Recipes for kids US Food Vegetarian recipes Bread recipes Drinks Meat Dishes Brisket recipes Caribou recipes Chicken recipes Filet mignons recipes Pork recipes Swordfish recipes Turkey recipes Pasta recipes Uncategorized recipes Ethnic recipes Canada recipes English recipes Ethiopia recipes Germany recipes Greece recipes Mexican recipes Philippines recipes Welsh recipes Microwave recipes Soups recipes Vegetable recipes Asparagus recipes Barley recipes Brown rice recipes Lentil recipes Mushrooms recipes Salads recipes Wild rice Desserts recipes Cakes recipes Chocolate recipes Cookies recipes Ice cream recipes