Google sheets doesn't use the same language as excel for 'macro' code. You would need to ask this question in a google sheets forum, not an excel forum.
If you do ask the question in another forum, please let them know that you have posted here as well, and let us know where you have posted the question. (see cross posting in forum rules).
That way, if someone here is able to answer your question, they will be able to check the other forum first to see if it has already been answered.