Monday, February 26, 2024

The Tissue Paper IQ Test

Tissues that come in cube-shaped boxes, “aka “cubes,” cost at least twice as much per tissue than those in the rectangular-shaped boxes. Both boxes cost about the same. But the cubes usually contain less than half the number of tissues as the rectangular-shaped boxes.

And yet my wife insists that I buy cubes. They take up less space on tables and the toilet tank; this is true, I admit. But still, I buy the rectangulars and then transfer the tissues into two empty cubes.

She complains about this and tries to throw away the empty cubes before I can refill them. But I persist.

I just can’t bring myself to buy cubes. I imagine the folks that monitor the security cameras look for people who are too stupid to realize that cubes are a bad deal. And then they post pictures of their subjects on some special website, similar to “People of Walmart.”

Is there a website called “People Who Pay Two Times More Than Necessary For Tissues” out there?  I doubt it, but I’m not taking any chances.

Sunday, February 11, 2024

Cybersecurity for Teachers

A kind reader suggested I share this cybersecurity resource for teachers:
https://www.vpnmentor.com/blog/teachers-guide-to-cybersecurity/

Here’s a brief overview of the topics it covers:
  • How Students Put You in Danger
  • The Internet in Your Classroom
  • The Hazards of Cyberbullying
  • An Educational Solution
  • Tips and Lesson Plans for Teachers
Thank you, RM!


LudditeGeek is not associated with vpnMentor, nor received any compensation for this post.

Saturday, February 03, 2024

Excel VBA -- Named Range Automation

A few weeks ago, I was working with an Excel workbook that had 18 sheets that were similar in structure. Half the sheets had names L1_1, L1_2, … L1_9; the other half, R1_1, R1_2, … R1_9. They contained dimensions of structures on the left and right of a substrate.

I wanted to display a summary of a few averages from each sheet on a new sheet. I knew this would involve the tedious process of selecting a range of cells for each average, so I decided I would write VBA code to create a named range for each group of cells that I wanted averaged.

I turned on the Macro Recorder and then manually created the range so I could get some idea of what object and property to set. It recorded this:

    ActiveWorkbook.Names.Add "PGC_1”, "=L1_1!$D$3:$D$84"

This told me that the Add method of the Names collection would require the Name and the Address of the desired named range.  And so I wrote this subroutine:

Sub CreateNamedRanges()
Dim objN As Name
Dim i As Integer, s As String

For i = 1 To 9
s = CStr(i)
ActiveWorkbook.Names.Add "PGC_" & s, "=L1_" & s & "!$D$3:$D$84"
ActiveWorkbook.Names.Add "PGL_" & s, "=L1_" & s & "!$D$190:$D$376"
ActiveWorkbook.Names.Add "PTL_" & s, "=L1_" & s & "!$D$101:$D$173"
ActiveWorkbook.Names.Add "PGR_" & s, "=R1_" & s & "!$D$190:$D$376"
ActiveWorkbook.Names.Add "PTR_" & s, "=R1_" & s & "!$D$101:$D$173"
Next i

For Each objN In ActiveWorkbook.Names
Debug.Print objN.Name, objN.RefersTo
Next

End Sub


But the code crashed on the fourth Add method; it complained about an invalid address.

It didn’t make sense. I looked carefully at the fourth Add method. There were no illegal characters or trailing whitespace or other pitfalls. I found references to the error online, but none of the content pertained to what I was working on.

Eventually it dawned on me that perhaps Excel was confusing the “=R1_” & s as an R1C1 style address. Perhaps I needed to make sure it knew that “=R1_” & s was a sheet name. And so I placed two single quotes in each address: one right after the equal sign, and one right before the exclamation mark, like this: "=’R1_" & s & "’!$D$190:$D$376"

After this correction, the code ran quickly.