Using the DMax Function …

… and an alternative.

In this discussion at Eng-Tips I recommended the use of the DMAX() function to extract maximum values from data grouped with different text labels.  In the process I needed to adjust the selection criterion to generate the correct results.  DMAX requires a criteria range of at least two rows and one or more columns.  In the simplest case the criterion consists of a column header with the criterion underneath; for instance:

=DMAX(datarange, 2, criteria)

Where criteria is a two row range containing:

First Name
Fred

Will return the maximum value from Column 2 from any row with the text “Fred” in the column headed “First Name”.

Unfortunatly this will not always work as expected, and in the example in the Eng-Tips discussion a criterion of M1 was also returning values from rows with labels M11, M12 etc.

The correct way to specify the criterion is to enter:

=”=M1″

which will appear as:

=M1

An alternative is to replace the DMAX function with an array function that will do the same job:

=MAX(IF(EXACT($C$7:$C$12928,U7),$E$7:$E$12928,-1000000))

In this case the labels are in Column C, the criteria are in Column U, and the data from which the maximum values are required are in column E.  The final negative number must be less than the most negative value in the datarange.

This formula must be entered as an array function (by pressing ctrl-shift-enter).  The screenshot below shows an example.

Array Formula as an alternative to DMax(), click to see full size

Array Formula as an alternative to DMax(), click to see full size

 
The array formula has the advantages:
  1. The criteria occupy only one cell, so may be placed in a list, next to the formula output
  2. The criteria consist only of the text, without an equals sign

Eng-Tips members may download an example spreadsheet from the link.

Posted in Arrays, Excel | Tagged , , , | 4 Comments

Randomising a list

A list can be sorted into random order by inserting a list of random numbers in an adjacent column and sorting both columns on the random number column.

A similar procedure can be carried out through a VBA subroutine, avoiding the need to insert a column of random numbers on the spreadsheet.  A spreadsheet incorporating this routine can be downloaded from: randomise list.zip

Features of this procedure are:

  • The range to be sorted is selected through a dialog box, with the default range being either the pre-selected range, or if there is no selection, the previously used range (if any).
  • The random number array is sorted using the combsort routine.
  • The range to be sorted can be a single column, or multiple columns.

The range selection dialog is shown in the screen-shot below:

Randomise a List

Randomise a List

Posted in Excel, VBA | Tagged , , | 2 Comments

Listing sheet names

Answering my own question from the previous post, here is a short UDF that will return a list of worksheet names, starting with any chosen sheet:

Posted in Excel, UDFs, VBA | Tagged , , , | 3 Comments

Extracting data from a 3D range

I recently needed to extract data from a series of tables on separate worksheets, into a form suitable for plotting on an XY graph.  In Lotus 123 this would be a piece of cake, since the Lotus @INDEX function has an optional third parameter allowing the sheet number to be selected.  Unsurprisingly, I could find nothing on the subject in the Excel help files, but surprisingly I couldn’t find anything on the Internet either.  I ended up using the INDIRECT() function, as shown in the screen shot below (click image to see full size):

Retrieve data from a 3D range using INDIRECT()

Retrieve data from a 3D range using INDIRECT()

I have entered sheet names in column B and the cell address in row 3, then the formula to retrieve the data to go in cell D5 is:
=INDIRECT(“‘”&$B5&”‘!”&D$3)
Note the $ signs that keep the address referring to the correct column and row when it is copied, and the apostrophe between the double quotes at the start and before the exclamation mark.  Also note that the sheet names in column B are now just the name as it appears on the tab, without the !.

Does anyone have an alternative method?
Is there a neat way to fill the sheet name column automatically?

Edited 27 August 09 following comments from Harlan Grove, who also provided some alternative ways of tackling it (see comments below)

Posted in Arrays, Excel | Tagged , , , | 3 Comments

Continuous beam with varying stiffness

Previous Splinebeam post

One of my aims in developing the splinebeam function is to carry out non-linear analysis of reinforced concrete beams, allowing for the greatly reduced flexural stiffness of reinforced concrete sections after cracking of the concrete.  To that end, I have added the facility to specify the section stiffness span by span.  Later versions will allow for the stiffness of individual segments to be specified, or for a non-linear moment-curvature relationship to be used. Dowload SplineBeam2_1.zip

The standard cubic spline formulation is based on the curvature and slope of the spline being continuous at nodes.  Since a step in the section stiffness will result in a step in the curvature, the curvature has been replaced by the bending moment, and the governing equation becomes:

SplineBeam2_1-1

SplineBeam2_1-2

The coefficients of the cubic splnie function must also be changed:

if: y = a + b(x – x(n)) + c(x – x(n))^2 + d(x – x(n))^3

where x lies between x(n) and x(n+1)

then:

SplineBeam2_1-3

Typical output for a 3 span beam is shown below:

SplineBeam2_1-4

Typical output; Click to view full size

A Strand7 analysis with the same input gives identical results:

SplineBeam2_1-5

Strand7 Output, Click to view full size

Posted in Arrays, Beam Bending, Excel, Finite Element Analysis, Maths, Newton, UDFs, VBA | Tagged , , , , , , , | 3 Comments