LoginSignup
0
0

More than 3 years have passed since last update.

ExcelVBA と GoogleSpreadSheet で「3×5=15」をマクロ記録で作成してみた。

Posted at

ExcelVBA

Sub s3kakeru5()
    Range("B3").Select
    ActiveCell.FormulaR1C1 = "3"
    Range("B4").Select
    ActiveCell.FormulaR1C1 = "5"
    Range("B5").Select
    ActiveCell.FormulaR1C1 = "=R[-2]C*R[-1]C"
    Range("B6").Select
End Sub

GoogleSpreadSheet

function _3kakeru5() {
  var spreadsheet = SpreadsheetApp.getActive();
  spreadsheet.getRange('B3').activate();
  spreadsheet.getCurrentCell().setValue('3');
  spreadsheet.getRange('B4').activate();
  spreadsheet.getCurrentCell().setValue('5');
  spreadsheet.getRange('B5').activate();
  spreadsheet.getCurrentCell().setFormula('=B3*B4');
  spreadsheet.getRange('B6').activate();
};

初回GASのエラーがでます。

承認が必要
このドキュメントに添付されたスクリプトを実行するには、あなたの許可が必要です。
続行 キャンセル

(参考)Google Apps Scriptの初回実行に必要となる承認手順
https://www.virment.com/step-allow-google-apps-script/

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0