Quantcast
Channel: Hot Weekly Questions - Web Applications Stack Exchange
Viewing all articles
Browse latest Browse all 9782

Simple Google Sheet Macro. Save it, Run it, Fail it... Range Not Found

$
0
0

Not sure what's going on here. I want to copy the data from one tabbed "sheet" within my Google Sheet to another.

I set up Record macro. Navigate to data sheet tab. Copy all (via click in top left corner, above row numbers, left of column letters, right click, copy). Go to different named blank tab within the same google sheet document. Select cell A1, Right Click Paste. End record macro.

Macro reads:

function Macrotest() {
  var spreadsheet = SpreadsheetApp.getActive();
  spreadsheet.getRange('A1').activate();
  spreadsheet.setActiveSheet(spreadsheet.getSheetByName('DataTab'), true);
  var sheet = spreadsheet.getActiveSheet();
  sheet.getRange(1, 1, sheet.getMaxRows(), sheet.getMaxColumns()).activate();
  spreadsheet.setActiveSheet(spreadsheet.getSheetByName('OutputTab'), true);
  spreadsheet.getRange('Sheet10!:').copyTo(spreadsheet.getActiveRange(), SpreadsheetApp.CopyPasteType.PASTE_NORMAL, false);
};

So far, so good. Clear out 'OutputTab' content. Run macro 'MacroTest()' directly from Tools Menu. Running Script shows in green alert box for 0.5 seconds, followed by red alert box, Range Not Found.

Huh? How is it possible that a recording of four of five mouse clicks can't repeat all within the same Google Sheet? What's going on here? Note: I don't want to duplicate() the tab, as the OutputTab has significant print formatting setups.

Is this a bug in the Google Sheets Recorder? Why would a simple record macro not function when asked to run?


Viewing all articles
Browse latest Browse all 9782

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>