A
A
Anoriella2019-02-08 11:48:44
Google Sheets
Anoriella, 2019-02-08 11:48:44

How to turn a formula into a macro?

Good day!
Such a problem, you need to turn the formula into an autorun macro with the following condition:
If( a1=1;u(a2=sheet2!A4;a5=sheet2!a5); if(a1=2;u(a2=sheet2!v6;A4= sheet2!v6);""))
In other words: when changing the value of one cell, the contents of others, which are taken from other sheets, should change.
The formula is inconvenient, because there are 30 such values, and there are 4 changing cells. It is also inconvenient to make 30 macros for each value.
Thank you!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
Grigory Boev, 2019-07-02
@ProgrammerForever

For this, it is convenient to use the onEdit(event) function.
Inside, we keep track of which cell has changed, and change what is needed.

function onEdit(event){
  //event.source.getActiveSheet().getName() для определения имени листа
  //event.source.getActiveSheet().getActiveRange().getA1Notation() для определения имени ячейки
};

If the formula is complex and multi-level, it is convenient to collect it in a text editor. You can write it in several lines for your convenience - Google tables don't care

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question