# Search and replace macro as a function in calc

Hi folks,

I'm trying to write a simple calculator in a music theory context which will calculate the distance between a note and a key center and then represent that distance in musical language, to be used in further calculations. The first part is okay, I just subtract the cell of the key center from the cell of the note in the MOD(12) function, so for F (5) in the key of G (7) I get =MOD([5]-[7],12), or 10, which is the interval of a minor 7 (m7).

I now want to represent that in musical language i.e. search and replace 0, 1, 2, 3, etc. with P1, m2, M2, m3, etc. respectively and I am under the impression that a macro as a function is the best way to do that. I only want it to affect the output cell, not the entire document, as there are other numbers being used that needn't be converted. I have looked into Andrew Pitonyak's work but I'm having trouble piecing together all the parts I need (multiple searches and replaces, use macro as function, confine to specific cells).

Thanks