returning two values

I have a function in which two indexes are calculated.  I would like to 
return them both.  Is this possible? 


0
srussell2458 (497)
9/24/2005 12:47:22 AM
vc.mfc 33608 articles. 0 followers. Follow

13 Replies
532 Views

Similar Articles

[PageSpeed] 3

"Steve Russell" <srussell@removethisinnernet.net> wrote in message
news:eg8tCGKwFHA.2516@TK2MSFTNGP12.phx.gbl...
> I have a function in which two indexes are calculated.  I would like to
> return them both.  Is this possible?

If they will fit, you could use something like MAKELONG. Otherwise you could
use OUT params.
-- 
Jeff Partch [VC++ MVP]


0
jeffp (1711)
9/24/2005 12:57:07 AM
"Jeff Partch [MVP]" <jeffp@mvps.org> wrote in message 
news:%23a2ShLKwFHA.2348@TK2MSFTNGP15.phx.gbl...
> "Steve Russell" <srussell@removethisinnernet.net> wrote in message
> news:eg8tCGKwFHA.2516@TK2MSFTNGP12.phx.gbl...
>> I have a function in which two indexes are calculated.  I would like to
>> return them both.  Is this possible?
>
> If they will fit, you could use something like MAKELONG. Otherwise you 
> could
> use OUT params.
> -- 
> Jeff Partch [VC++ MVP]
--------
Thanks, Jeff. 


0
srussell2458 (497)
9/24/2005 4:11:18 AM
Hi Jeff,
you ought to think about a more sophisticated solution. Define a
structure and let the function return this structure.
In this structure you declare as many separate values as you need.
I do it in some of my apps whenever I need it.
ThoK

0
9/24/2005 6:25:35 AM
"ThoK" <ThoKKregeloh@aol.com> wrote in message
news:1127543135.482473.148290@z14g2000cwz.googlegroups.com...
> Hi Jeff,
> you ought to think about a more sophisticated solution. Define a
> structure and let the function return this structure.


You mean allocate it in the function and return a pointer to it?



0
jeffp (1711)
9/24/2005 11:49:24 AM
I do the following in order to return the complex result of a function,
where iReturn is a status (ended with OK or Cancel) and some other
value(s) which are the result of the function. The following is a
converted demo of what my function really does.

>> snippet of application.h
struct stComplexResult
{
  int     iReturn;
  CString csResultField1;
  int     iResultField2
};
// function header
stComplexResult    ComplexCalculation(int);

>> snippet of application.cpp
stComplexResult    ComplexCalculation(int iParm1)
{
stComplexResult    stResult;
....
stResult.iReturn    = 0;
stResult.csResultField1 = "Field 1 of the result";
stResult.iResultField2 = iParm1;
return stResult;
}

>> snippet of applicationDlg.cpp
stComplexResult    ComplexCalculationResult;

ComplexCalculationResult = ComplexCalculation(20);
// Now you have three values:
// ComplexCalculationResult.iReturn, which is 0
// ComplexCalculationResult.csResultField1, which is ,,Field 1 of the
result"
// ComplexCalculationResult.iResultField2, which is 20

That's the way I would do it
ThoK

0
9/24/2005 1:59:51 PM
Lots of ways.  It depends on what you want to get out of the code.


void ComputeIndices(int &a, int & b) { a = ...; b = ...; }

then call it passing in two integer variable names .  
int a;
int b;
ComputeIndices(a, b);

typedef struct {int a; int b; } Indices;

Indices ComputeIndices()
    {
     Indices result;
     result.a = ...;
     result.b = ...;
     return result;
    }

and call it as

Indices result = ComputeIndices();

or you can return one as a result and one via a reference

int ComputeIndices(int & b);

int b;
int a = ComputeIndices(b);

Or, you can use pointers if the result can be optional

int ComputeIndices(int * b)
   {
    int result = ...;
    if(b != NULL)
        *b = ...;
    return result;
   }

and call it as

int a = ComputeIndices(NULL);
or
int b;
int a = ComputeIndices(&b);
or even

int ComputeIndieces(int * b = NULL);

int a = ComputeIndices();
if all you need is one.
					joe


On Fri, 23 Sep 2005 20:47:22 -0400, "Steve Russell" <srussell@removethisinnernet.net>
wrote:

>I have a function in which two indexes are calculated.  I would like to 
>return them both.  Is this possible? 
>
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
newcomer (15975)
9/24/2005 5:08:42 PM
That's more along the line of what I was thinking, only better.  Thanks, 
Joe.
--------------
"Joseph M. Newcomer" <newcomer@flounder.com> wrote in message 
news:hn1bj1160i4rr3hcv7p1ape6q6g91scd6b@4ax.com...
> Lots of ways.  It depends on what you want to get out of the code.
>
>
> void ComputeIndices(int &a, int & b) { a = ...; b = ...; }
>
> then call it passing in two integer variable names .
> int a;
> int b;
> ComputeIndices(a, b);
>
> typedef struct {int a; int b; } Indices;
>
> Indices ComputeIndices()
>    {
>     Indices result;
>     result.a = ...;
>     result.b = ...;
>     return result;
>    }
>
> and call it as
>
> Indices result = ComputeIndices();
>
> or you can return one as a result and one via a reference
>
> int ComputeIndices(int & b);
>
> int b;
> int a = ComputeIndices(b);
>
> Or, you can use pointers if the result can be optional
>
> int ComputeIndices(int * b)
>   {
>    int result = ...;
>    if(b != NULL)
>        *b = ...;
>    return result;
>   }
>
> and call it as
>
> int a = ComputeIndices(NULL);
> or
> int b;
> int a = ComputeIndices(&b);
> or even
>
> int ComputeIndieces(int * b = NULL);
>
> int a = ComputeIndices();
> if all you need is one.
> joe
>
>
> On Fri, 23 Sep 2005 20:47:22 -0400, "Steve Russell" 
> <srussell@removethisinnernet.net>
> wrote:
>
>>I have a function in which two indexes are calculated.  I would like to
>>return them both.  Is this possible?
>>
> Joseph M. Newcomer [MVP]
> email: newcomer@flounder.com
> Web: http://www.flounder.com
> MVP Tips: http://www.flounder.com/mvp_tips.htm 


0
srussell2458 (497)
9/24/2005 8:08:17 PM
No need, most will just binary copy, VC placing assign allocators as 
required.

-- 
- Mark Randall
http://zetech.swehli.com

"Those people that think they know everything are a great annoyance to those 
of us who do"
    Isaac Asimov

"Jeff Partch [MVP]" <jeffp@mvps.org> wrote in message 
news:eouGA4PwFHA.2960@tk2msftngp13.phx.gbl...
> "ThoK" <ThoKKregeloh@aol.com> wrote in message
> news:1127543135.482473.148290@z14g2000cwz.googlegroups.com...
>> Hi Jeff,
>> you ought to think about a more sophisticated solution. Define a
>> structure and let the function return this structure.
>
>
> You mean allocate it in the function and return a pointer to it?
>
>
> 


0
yr (150)
9/24/2005 10:11:38 PM
In general, how do you decide whether to use a struct or a class?
---------------------
"Joseph M. Newcomer" <newcomer@flounder.com> wrote in message 
news:hn1bj1160i4rr3hcv7p1ape6q6g91scd6b@4ax.com...
> Lots of ways.  It depends on what you want to get out of the code.
>
>
> void ComputeIndices(int &a, int & b) { a = ...; b = ...; }
>
> then call it passing in two integer variable names .
> int a;
> int b;
> ComputeIndices(a, b);
>
> typedef struct {int a; int b; } Indices;
>
> Indices ComputeIndices()
>    {
>     Indices result;
>     result.a = ...;
>     result.b = ...;
>     return result;
>    }
>
> and call it as
>
> Indices result = ComputeIndices();
>
> or you can return one as a result and one via a reference
>
> int ComputeIndices(int & b);
>
> int b;
> int a = ComputeIndices(b);
>
> Or, you can use pointers if the result can be optional
>
> int ComputeIndices(int * b)
>   {
>    int result = ...;
>    if(b != NULL)
>        *b = ...;
>    return result;
>   }
>
> and call it as
>
> int a = ComputeIndices(NULL);
> or
> int b;
> int a = ComputeIndices(&b);
> or even
>
> int ComputeIndieces(int * b = NULL);
>
> int a = ComputeIndices();
> if all you need is one.
> joe
>
>
> On Fri, 23 Sep 2005 20:47:22 -0400, "Steve Russell" 
> <srussell@removethisinnernet.net>
> wrote:
>
>>I have a function in which two indexes are calculated.  I would like to
>>return them both.  Is this possible?
>>
> Joseph M. Newcomer [MVP]
> email: newcomer@flounder.com
> Web: http://www.flounder.com
> MVP Tips: http://www.flounder.com/mvp_tips.htm 


0
srussell2458 (497)
9/25/2005 4:17:37 AM
Steve Russell" <srussell@removethisinnernet.net> wrote:
> In general, how do you decide whether to use a struct or a class?
> ---------------------

As said, in general they are identical appart from with a struct the default 
access is public, and the default inherit is public, in a class its private.

Personally; I go for structs when im just going to go setting / messing 
about with data inside it directly (mystruct.var1 = 1) and I go for classes 
when I need to manage access to them and perform functions on them 
(myclass.SetVar1(1));

-- 
- Mark Randall
http://zetech.swehli.com

"Those people that think they know everything are a great annoyance to those 
of us who do"
    Isaac Asimov 


0
yr (150)
9/25/2005 9:08:29 AM
I have no specific criteria.  Mostly I use classes; I'll use a struct if I have a simple
object, with only public members.
				joe

On Sun, 25 Sep 2005 10:08:29 +0100, "Mark Randall"
<mark[__OKTHISISFAKE_]yr@REMOVETHISgoogle.ANDTHIScom> wrote:

>Steve Russell" <srussell@removethisinnernet.net> wrote:
>> In general, how do you decide whether to use a struct or a class?
>> ---------------------
>
>As said, in general they are identical appart from with a struct the default 
>access is public, and the default inherit is public, in a class its private.
>
>Personally; I go for structs when im just going to go setting / messing 
>about with data inside it directly (mystruct.var1 = 1) and I go for classes 
>when I need to manage access to them and perform functions on them 
>(myclass.SetVar1(1));
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
newcomer (15975)
9/26/2005 7:03:00 AM
On Sun, 25 Sep 2005 00:17:37 -0400, "Steve Russell"
<srussell@removethisinnernet.net> wrote:

>In general, how do you decide whether to use a struct or a class?

See:

http://www.parashift.com/c++-faq-lite/classes-and-objects.html#faq-7.8

>> typedef struct {int a; int b; } Indices;

Note you would never write the above in C++, and even in C, it's
suboptimal. In C++, you would write:

struct Indices
{
   int a;
   int b;
};

In C, you would write:

typedef struct Indices
{
   int a;
   int b;
} Indices;

You should always include the struct tag in C, and it should have the same
name as the typedef, not the "tagIndices" silliness you sometimes see in
the Windows headers.

-- 
Doug Harrison
VC++ MVP
0
dsh (2498)
9/26/2005 3:48:37 PM
I use structs so rarely that I still use the fairly old-fashioned syntax when I use it at
all.
				joe

On Mon, 26 Sep 2005 10:48:37 -0500, "Doug Harrison [MVP]" <dsh@mvps.org> wrote:

>On Sun, 25 Sep 2005 00:17:37 -0400, "Steve Russell"
><srussell@removethisinnernet.net> wrote:
>
>>In general, how do you decide whether to use a struct or a class?
>
>See:
>
>http://www.parashift.com/c++-faq-lite/classes-and-objects.html#faq-7.8
>
>>> typedef struct {int a; int b; } Indices;
>
>Note you would never write the above in C++, and even in C, it's
>suboptimal. In C++, you would write:
>
>struct Indices
>{
>   int a;
>   int b;
>};
>
>In C, you would write:
>
>typedef struct Indices
>{
>   int a;
>   int b;
>} Indices;
>
>You should always include the struct tag in C, and it should have the same
>name as the typedef, not the "tagIndices" silliness you sometimes see in
>the Windows headers.
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
newcomer (15975)
9/27/2005 1:38:20 AM
Reply:

Similar Artilces:

find largest value in a row
I have a spreadsheet with bridge component ratings in three columns. I need to find the largest of the three and have it put into another column. I've tried to use INDEX and MATCH, but can't quite get it to work. All the examples I've found have had slightly different end goals, and I'm not adjusting the formula correctly. Can someone help? (I tried to include a sample table, but how do you get it to line up correctly?) Do you mean to find the largest of 3 values and put that into the adjacent column ? Try MAX(B2:D2). Bas Hartkamp. <vicki.wells@modot.mo.gov> sc...

Sorting Values
Please help. I have a field containing values ex. 1/01/0228, 2/01/2008, 3/01/2008. When i get to 10/01/1008 and 11/01/2008. Access sort it as follow: 01/01/2008, 10/01/2008, 11/01/2008, 2/01/2008, 3/01/2008. How can i get the sorting to stay 1/012008, 2/01/2008 3/01/2008..........10/01/2008, 11/01/2008? Hi Francois, Is the data type for your field set as Text? It appears as if your data represents dates, although some of the years look a bit suspicious... Try changing the data type to Date / Time Note: You may not have success making this change if you have data that is not a valid d...

Enter two consecutive sales for liquidating/discontinued product
Liquidating or Discontinuing a product line - I want products to go on sale for a certain period say 2 weeks or a month. Anything that has not sold will be reduced again for another 2 weeks or month, and then again if not completely liquidated. Each "period" sale will be for even greater discounts. I want to add all these consecutive sales/discounts at one time rather than having to wait for one sale to end before I can enter the next. When I tried to put in the second period of discounts it wiped out all my current period discounts. Kathryn Wings of Joy ---------------- Th...

return checkbox value
I am using '97 and I can't seem to return the value of the checkbox. x = Sheets("New Report").textbox1.Value -- Thanks, Ron Hi Ron, I don't see where you are checking the value of a combobox. Dan You used .textbox1.value Did you want .checkbox1.value???? Ron5440 wrote: > > I am using '97 and I can't seem to return the value of the checkbox. > x = Sheets("New Report").textbox1.Value > -- > Thanks, > Ron -- Dave Peterson ...

Really appreciate some help on merging two spreadsheets...
Hi All, I have two spreadsheets - one of them has a list of addresses and bandwidth requirements per site for a VPN. The other sheet has the same addresses in a different order with postcodes. I need to merge them together so I have one sheet which has both the bandwidth and the postcodes - is there any easy way to do this? Appreciate your help in advance. Rob. Yes: check out VLOOKUP in Help. It will look up an item in a range and return another cell from within that range. Note, however, that the spelling of site names or whatever your lookup value is must match exactly. Please po...

two (or more) crossfunctional flowcharts on the same page?
Hi. I have to build a lot of crossfunctional flowcharts. Some of them are small, but the functions are different for each and every one of them. Furthermore, some of them are linked to each other. It would be a waste of paper to put and print every one on an individual page. So I wonder if there is any possibility to put two or more on the same page. Till now (2 months), all my efforts were in vain. I appreciate any suggestion. Thanks. ...

Setup Question
I am having trouble finding clear information and advice about how to set up my Money file. I would like to set up Money so that my girlfriend and I can track bank accounts, investments and expenses that we have jointly (including our mortgage and rental property). However, we also both have separate bank accounts, investments and expenses that are unrelated to each other. I don't know whether I should set up two separate files or set up all of our information in one file that we have to share. I really want to avoid having to enter our shared accounts and expenses twice, so ...

Conversion to value between 1 to 10 only!
I have a problem for an excel formula. In my example, there is one value in cell D1: 15, and I want an excel formula which can convert it to 5. The objective of the excel formula is to convert 45 to 5, 10 to 10, 20 to 10, 30 to 10, 39 to 9 etc. I know my following excel function can do it 【IF(D1>40,D20-40,IF(D1>30,D1-30, IF(D1>20,D1-20,IF(D1>10,D1-10,D1))))】. My question is that is there any extremly simple excel formula which can convert those value immediately? Many thanks, Wilchong -- Message posted via http://www.officekb.com =D1-LOOKUP(D1,{10,20,30,40},{10,20,3...

how do I print just one side on a two sided post card
How do I print off a post card using mailmerge with publisher. I can do printing on both sides only for each individual sheet. I would like to be able to print each side seperately. Can't figure it out. Duplicate the original file twice so that you have 3 files. Delete side one from the first file and side two from the second. The third is the original and remains unaltered. -- Ron Cohen "rush" <rush@discussions.microsoft.com> wrote in message news:7DC33F86-DA8E-428D-AD06-A90636BDD9E1@microsoft.com... > How do I print off a post card using mailmerge with publi...

Enter Parameter value problem
I have a database which has been in use for quite some time. Recently I changed a field name in TableA from county to country. This table is related to TableB and TableC and also part of a query. Now when I open TableA or TableB or the query, a dialog box opens asking "Enter Parameter Value" for TableA.county with the blank datasheet in the background (only the first field of the first record is filled). If I click OK or cancel or Esc the dialog box disappears and the datasheet fills up with all the records. I have looked at the query and the tables in design view but can...

Two variables
I hope someone can help! I have a number of workbooks with various staff data including staff costs and proportion of time worked and cost centre by individual employee in one worksheet and need to do some analysis of this based on staff category in another sheets withinh the individual workbooks. I have proportion in column "N", category in "F" and cost centre in "M". Cost centres are in the format C********* and other cost centres start with either H or O The info has to be reported against staff category and cost centres (split between "C" an...

copy a formula over two rows but increase the row # by 1 only
How do you copy a formula from one cell in row "a" to row "c", but only increase the row reference to "b" automatically? Dave, Copy it to row 'b' then drag the copy from 'b' to 'c' HTH, Bernie MS Excel MVP "Dave" <Dave@discussions.microsoft.com> wrote in message news:5F8E96F9-15A7-4742-AC0D-40A0D64F14D9@microsoft.com... > How do you copy a formula from one cell in row "a" to row "c", but only > increase the row reference to "b" automatically? Rows are numbers, columns are letter...

Receipt with waranty message and product return policy.
I have a customer who has request a receipt message be added. Do we have a way of servicing this request ? It would be great if it was printed on demand according to the the selected item. Well, adding text to ALL receipts is easy - just create some more footer text lines (I think the default template accomodates 5 lines). Adding text based on specific items is not so easy - you will probably need an Add-in that either writes the text or a flag to a session variable to do this. Start out by downloading the Customization Guide from Partner Source as this will give you the basics of bo...

Default SQL database values
Í create some new tables fomr dexterity, suing the following code if Table_SetCreateMode(true) <> true then ErrorEncountered = true; abort script; end if; open table ncPOS_CustAttrib as DB_TYPE_TABLEDEFAULT; close table ncPOS_CustAttrib; if nc_Grant_Table_Access(Runtime_GetCurrentProductID(),technicalname(table ncPOS_CustAttrib),'Intercompany ID' of globals) <> true then ErrorEncountered = true; end if; if Table_SetCreateMode(false) <> true then ErrorEncountered = true; abort script; end if; the function nc_Grant_Table_Access grant permision to the user...

x-values revert to item number
I've just reloaded Excel 97 on a new computer running Windows XP. When plotting $A1:$A10 vs $B1:$B10, the plot is fine. When adding a series, $A11:$A20 vs $B11:$B20, the x-values in the 2nd set revert to a simple series, 1,2,3,4,5..., rather than the value in the series itself. When plotting the second series in a separate graph, the same thing happens: my x-values, instead of being 3,5,5,9,22, are 1,2,3,4,5. Thanks for any help. Change from "Line" Chart to "XY (Scatter)" Chart. Jerry cole pierce wrote: > I've just reloaded Excel 97 on a new comput...

matching a sorting the exact value in the data list
Hi there, In Excel 2000 I wish to match and sort the following data using some type of function in Excel. CRXU1972999 CRXU1972509 CRXU1973932 CRXU1972999 DFSU6001327 CRXU1973932 GESU2271222 FCIU2056631 GESU9254295 GESU2271222 PCIU3025511 PCIU2365754 PCIU3030457 PCIU3023571 PCIU3038329 PCIU3025511 PCIU3039304 PCIU3026020 PCIU3055060 PCIU3030457 PCIU3060600 PCIU3038329 PCIU3061993 PCIU3039304 PCIU3066085 PCIU3060600 ....so the above mentioned data should look like this(see below) after the function has been applied. CRXU1972999 CRXU1972999 (wish to join but in seperate columns) CRXU19739...

One Exchange server with two domains
We have 2 e-mail domains. DOMAIN1.COM and DOMAIN2.COM Exchange is setup with DOMAIN1.COM being the actual domain but it is also configured to accept mail for the DOMAIN2.COM domain. Each user has 2 e-mail addresses. John.Doe@domain1.com and John.Doe@domain2.com. One person has 4 e-mail addresses. Jane.Doe@domain1.com, Jane.Doe@domain2.com, info@domain1.com and info@domain2.com. The MSCRM EMailRouter is having an issue with e-mail addresses other than the address that is the default domain. Any thoughts on how to handle this situation? Thanks! Michael Cross Navint http://www.navi...

Assign value based on sort
Hi Groupies! I am in the final stages of a database for a golf tournament and I would like to automate the flighting, hole assignment and tee time for the final round. I have a query (qrySatFlights) that calculates a total score based on the first two rounds of golf, the field is called SubTotal. Based on the value in SubTotal, I would like Access to assign the correct values in the Flights field, the SatHole field and the SatTeeTime field. Here is what needs to happen: For the first 9 flights there are 16 golfers. The 16 players with the lowest SubTotal go in the Championship Flight...

IF need to add a third value
my formula is =IF(B5>=C5,"G","Y") I really need to add a third value of "R" if the logical test exceeds a value beyond what is in the current formula. Thanks in advance for your assistance! Hi, You can use as many if() functions as needed. For example, =If(B5>=C5,"G",If(B5>=D5,"R",....,"Y")) and so on. Hope this helps Regards, Emece.- "GMv1" wrote: > my formula is =IF(B5>=C5,"G","Y") I really need to add a third value of "R" > if the logical test exce...

Find a carriage return in a worksheet
I have a big Excel file that has been saved as a CSV file. We need to upload this file to SAP. However, some cells contain a carriage return (it is displayed as a square in the cell). I need to fix all the rows that have the carriage return. Is there a way to FIND a cell with carriage return ? ie. by using the FIND function. Hi Select one of the cells with the carriage return. Copy it from the "Formula Bar" then Enter. Now select your data and go to Edit>Replace paste in the carriage return to the "Find What" box and leave the "Replace With" Blank or, t...

Charts for 2008 with No Values #2
David and Andy, Thanks for your posts. Whether I use #N/A or =NA() I get the value 0 on my chart and it is plotted so it looks like the value has gone down to zero. I do not even want the line after November since we have not yet closed 12/2007. The cell was originally formatted as a number and I tried number, general, as well as text and nothing works. All return 0 and it is plotted with a line. Thanks for your help. What's the formula in these cells? - Jon ------- Jon Peltier, Microsoft Excel MVP Tutorials and Custom Solutions Peltier Technical Services, Inc. - http://PeltierTech...

How to Link a cell in an Excel spread sheet to a text value in Visio 2007
I would like to have a text value in Visio take the value of a cell in an Excell spread sheet. Is there a way to do this, at least on opening the Visio Document? Thanks in advance, Marco UCO Lick Observatory Laboratory for Adaptive Optics visio 2007 professional http://office.microsoft.com/en-us/visio/HA100518191033.aspx al "Marco" <null@null.net> wrote in message news:uCcafQkuKHA.1796@TK2MSFTNGP02.phx.gbl... > I would like to have a text value in Visio take the value of a cell in an > Excell spread sheet. Is there a way to do this, at leas...

Setting a Cell's Value Based on Another Cells Contents
I can't imagine that this is as hard as I'm making it... but admittedl I am having some trouble, so here's my post....... I have two columns, the first (D) is titled Job Specialty Area an contains a dropdown list of 30 job types including one for "Other Jo Specialty Area". The other column is (E) and titled "Or Other..." , an allows the user to type in their own job specialty area (instead o choosing one from the list). The goal, if a user starts typing in column E, to default column D t "Other Job Specialty Area...." ANY ideas, comments, suggestio...

link chart axis scale to spreadsheet cell value
Hello, I have a simple column chart. I would like to be able to set the maximum & minimum values of the horizontal axis according to numeric values in 2 of the spreadsheet cells. I cant see a way of doing this. Is there a trick ? Thanks KK Hi, There is no trick. It required VBA code to do it. http://peltiertech.com/Excel/Charts/AxisScaleLinkToSheet.html Cheers Andy -- Andy Pope, Microsoft MVP - Excel http://www.andypope.info "KRK" <trebor@yeleek.nospam.freeserve.co.uk> wrote in message news:ufmS8gSsJHA.5112@TK2MSFTNGP03.phx.gbl... > Hello, > > I have...

Allocating a value to text
I have a to work out a rota. A night shift is put down as an N and is 15 hours long. Day Shift D 10 hours long and L 5 hours long. I need to work out peoples hours. I don't know how to get excel to allocate a value to N, D & L so it can do a sum. FOR EXAMPLE: (I need a sum of hours worked in column H) A B C D E F G H 1 N N N Off Off Off 2 L L L D D Off 3 D D D Off Off Off 4 5 6 7 8 9 Many thanks Steve (A poor over worked Nurse!) Try this: =(COUNTIF(A1:E1,"n")*15)+(COUNTIF(A1:E1,"d")*10)+(COUNTIF(A1:E1,"...