Creating a Complex What if in Excel: Beyond Nested Conditionals
There are many ways with either VBA or Excel formulas, in both look at the
Mod function.
Perhaps a named formula -
Select cell B1
Ctrl-F3 Define names
Name: Note
Refersto (enter following as one line)
=INDEX({"C","Db","D","EB","E","F","Gb","G","Ab","A ","Bb","B"},MOD(A1,12)+1)
in the cell offset one to right of your number enter =Note
One way with a UDF
Function fnNote(number)
Static bGotArray As Boolean
Static arrKeys
On Error GoTo errh
If Not bGotArray Then
arrKeys = getKeys
bGotArray = True
End If
x = arrKeys(number Mod 12)
fnNote = arrKeys(number Mod 12)
Exit Function
errh:
fnNote = CVErr(xlValue)
End Function
Function getKeys()
getKeys = Array("C", "Db", "D", "EB", "E", "F", _
"Gb", "G", "Ab", "A", "Bb", "B")
End Function
=fnNote(A1)
Regards,
Peter T
wrote in message
oups.com...
I'm trying to create a complex set of variables in an excel
spreadsheet. Since I am not a strong programmer, the best way to do
this is to basically use a very complex if/then argument. However,
excel only supports 7 nested conditionals.
Basically, what i want to do is "teach" excel the notes of a music
keyboard in terms of number.
Ex 60 = C, 61 = Db, 62 = D etc etc...and so on for all 127 notes of a
midi keyboard.
In other words, like an array or list that I can do calculations with.
Any advice?
|