On Mon, 2005-11-28 at 03:54 +0000, Terry North wrote:
> mattias davidsson <mattias.davidsson <at> comhem.se> writes:
> ... in two, or more rows I have the following cell values
> > 23-25, 26  the row for this cell would be split into several rows, one for
> each number, ie the row with the cell would be split into rows with the cell
> values 23, 24, 25 and 26 where the values in the other columns for the row are
> copied 
> > from the oringial row where the cell was.
> > 
> > is this understandable?
> ...[previous:]
> > > I would like to do one of two things
> > > 1.  calculate the following from different cell values
> > > from cell value 1-4, 7-9    (describing ranges of weeks)
> > > I would like to calculate the number of weeks, in this case 7.
> > > From cellvalue 2-4, 5,6
> > > the same thing, number of weeks is now 5
> > > or any variant of the above..
> > > the result should be put in a new cell in a new column
> ...
> I for one do not understand.  It might help if you include a pasting from an
> actual spreadsheet. If I put 1-4, 7-9 into a cell, it is probably a label, 
> not a
> value.  Certainly, it does not seem to be possible to manipulate such an entry
> with a formula.

I think what you would have to do here is to implement a macro.
You could try the following pseudo-code as an example to start coding.

Function GetWeeks( sWeekString ) 

    weeks = 0
    Weeks[] = split( sWeekString, ',')
    for each week in Weeks[] do
        if (week contains '-') then
                (first,last) = split( week, '-' )
                weeks = weeks + (last - first) + 1
        else
                weeks = weeks + 1
        end if
    end for
    GetWeeks = weeks
End Function

Regards
Jonathon
-- 
OOo Tips:               http://mindmeld.cybersite.com.au/tips.rss
OOo Knowledgebase:      http://mindmeld.cybersite.com.au
Training4Linux:         http://www.training4linux.com
Cybersite Consulting:   http://www.cybersite.com.au


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to