Deletionists vs Inclusionists

Port Macquarie is a small Australian coastal town just up the road from me (360 km, according to Google), which has a fairly undistinguished Presbyterian Church:

PortMacQPC

This church used to have its own article in Wikipedia, but the Wikipedia deletionists decided that it was insufficiently distinguished for such an honour, and deleted it, which was recorded by the Belligerati Blog in August 2008.

James Gleick (who does have a Wikipedia entry) came to hear of this, and wrote of it in his 2011 book “The Information”, so now The Port Macquarie Presbyterian Church has the unique quality of being the only Presbyterian Church having been mentioned by a Wikipedia-worthy author as having been deleted from Wikipedia.

This would surely make the church of sufficient note to be included in Wikipedia, but then its one claim to fame as a church deleted from Wikipedia would be gone, and they would have to delete it again.

And so on …

Posted in Bach | Tagged , , , , , | Leave a comment

Lift Humour

I recently received an e-mail link to this comedy sketch set in a voice recognition lift in Scotland:

which reminded me of this Woody Allen sketch from nearly 50 years ago:

It seems that neither voice recognition technology nor humour is advancing as fast as is often claimed.

Posted in Bach | Tagged , , | 1 Comment

Chain mail …

… or a collection of inter-connected links (all e-mailed by Alfred Vachris, and all worth a look):

3D scatter plot for MS Excel – free spreadsheet with proper 3D scatter plot function.

Excel Liberation

This is not another Excel tips and tricks site (although there is inevitably some of that). The aim of Excel Liberation and its related blog is to encourage you to take advantage of web capabilities without being constrained by having to do things the ‘Microsoft way’. You’ll see a few techniques, tips and tricks for sure, as well as fully functional sample applications in various languages and frameworks.

Engram 9 VBA Scripts – VBA blog, including Excel, Outlook and Autocad applications.

Dead Reckonings

This journal attempts to capture in brief essays my encounters with the technically elegant but nearly forgotten in the mathematical sciences–artistically creative works that can take our breath away with their brilliance.

Jorge R Viramontes Olivas – Maths, the Universe, and everything, including an assortment of JavaScript based apps.

Science v Magic – More JavaScript apps, including fractals, cellular automata, and geometry.

Posted in Excel | Leave a comment

Select and sum data using the scripting dictionary

Another User Defined Function (UDF) prompted by a query at Eng-Tips.

The question concerned a set of data consisting of 13 columns, which was to be divided into two sets, based on the contents of Column 4, then the contents of columns 6 to 11 were to be summed for each row with identical contents in columns 12 and 13.

The first attempt copied the data into two arrays (based on the contents of Column 4), then did a nested loop, for each row of Array1 looping through all of Array2, and adding the contents of Array2 to the current row of Array1, when columns 12 and 13 were identical in each array.  This worked, but was extremely slow, taking about 4 minutes for 50,000 rows of data.

One way to speed up the process would be to sort both arrays based on the contents of columns 12 and 13, then exit each loop when the columns no longer matched.  An easier and more efficient way though is to create a dictionary object; the algorithm is:

  • Copy the data into two arrays, based on the contents of Column 4
  • Create a dictionary object of Array2, using a key formed from the combined text of columns 12 and 13, and an Item value of the row number.
  • Whenever a later row in Array2 is found matching an existing dictionary key, the values of columns 6 to 11 are added to the matching row.
  • Loop through Array1, and add the contents of columns 6 to 11 from the first matching row in Array 2, using the dictionary to identify the row number

The revised routine reduced the time for 50,000 rows from more than 4 minutes to less than 1 second!

The spreadsheet can be downloaded from SelectSum.xlsb, including full open source code.

The function SumSelectD can be used as an array function directly on the spreadsheet, or run the routine CopySumDict to use the data on sheet1, and copy the results to sheet2.  Note that the subroutine needs three named ranges:

  • TLD: the top left cell of the input data
  • Criteria: five cells in a column, defining the selection criteria
  • Results:  A range of two or more cells at the top left of the output range (the subroutine automatically resizes this range to accommodate the output data).

Also note that the code includes the original, very slow, routines (SumSelect and CopySum).  These will work, but may take several minutes to process a large range of data.

Finally, the spreadsheet also includes another short UDF using the scripting dictionary, taken from Daily-Dose-of-Excel.  This UDF counts the number of unique items from a comma delimited list in a spreadsheet cell.  The download file includes an example, and the full code is shown below:

Function F_unique(c00)
Dim sn As Variant, j As Long, c01 As Long, Dict As Scripting.Dictionary
sn = Split(c00, ",")

Set Dict = New Scripting.Dictionary

With Dict
For j = 0 To UBound(sn)
c01 = .Item(Trim(sn(j)))
Next
F_unique = .Count
End With
End Function

See the DDoE post for an even shorter version.

F_Unique Function

F_Unique Function

 

Note that to use the scripting dictionary you need to create a reference to “Microsoft Scripting Runtime” under Tools-References in the Visual Basic Editor.

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

EvalA update and examples

The EvalA User Defined Function (UDF) has been included in the Eval2 and Eval-Integration spreadsheets for some time, but was not documented.  That has now been fixed, and both spreadsheets can be downloaded from Eval2.Zip (including full open-source code).

The original Eval UDF evaluates a function entered as text on the spreadsheet, substituting values for specified parameters.  See: https://newtonexcelbach.wordpress.com/2012/10/01/daily-download-15-evaluation-of-formulas-in-text/
for more details.

EvalA performs the same task, but also allows one or more variables to be replaced with a range of values, returning a column array of results.  This allows graphs of the functions to be plotted and edited quickly and easily.  Two examples are shown below:

EvalA

AS 3600 Creep Coefficient, k2

AS 3600 Creep Coefficient, k2

The function must be entered as an array function to return all the results:

  • Enter the function (or copy and paste) in the top cell of the output range.
  • Select the complete output range (including the top cell)
  • Press F2 (Edit) then Ctrl-Shift-Enter

See https://newtonexcelbach.wordpress.com/2011/05/10/using-array-formulas/ for more details.

Posted in Arrays, Charts, Excel, Maths, Newton, UDFs, VBA | Tagged , , , , | Leave a comment