After wasting some time reading manuals, Google found the answer here: http://www.ozgrid.com/VBA/run-macros-change.htm
This is the VBA code that now updates my “grams” column when the “ounces” column changes, and v.v. Column F is “ounces” and column H is “grams”.
Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
‘do nothing if more than one cell is changed or cell was cleared
If Target.Cells.Count > 1 Or IsEmpty(Target) Then Exit Sub
‘if changing ounces, then update grams
If Not Intersect(Target, Range(“F2:F65536”)) Is Nothing Then
If IsNumeric(Target) Then
On Error Resume Next
Application.EnableEvents = False
Target.Offset(0, 2).Value = Target.Value * 28.35
Application.EnableEvents = True
On Error GoTo 0
End If
End If
‘ if changing grams, then update ounces
If Not Intersect(Target, Range(“H2:H65536”)) Is Nothing Then
If IsNumeric(Target) Then
On Error Resume Next
Application.EnableEvents = False
Target.Offset(0, -2).Value = Target.Value / 28.35
Application.EnableEvents = True
On Error GoTo 0
End If
End If
End Sub
It’s not very elegant and can probably be cleaned up, but it works. Unfortunately, VBA is Microsoft Excel specific, and the updating didn’t occur when running the spreadsheet in OpenOffice.org. I guess, in that environment, one of the columns will need to be a formula based on the other.
In my spreadsheet between columns F and H is column G, “pounds”. The formula in this column is (from cell G2):
=IF(F2=””,””,IF(F2>16,INT(F2/16)&”# “,””)&IF(MOD(F2, 16) < 10, " ","")&FIXED(MOD(F2, 16),1,0))
This displays a nicely formatted pounds column (e.g., “Black Pine 0F sleeping bag” is “8# 4.0”). I’m too lazy to write a parser to make a pounds-column entry update the ounces and grams columns.
The other day I added outlines with subtotals, so now I need to clean up and reorganize my list into groups.
P.S. Arrrrgh! The column update DOESN’T always occur if you change a value and use an arrow key to move to a different cell. You have to press <enter>, move back into the cell with an arrow key, or click the cell to get it to update. Sigh. Typical Microsoft.
PPS. Except when it DOES. Also, it thinks fomulas are numeric, so it will gladly stomp subtotals and other calculations if you even click on the cell. I’m not sure this auto-update feature is really worthwhile!