Is there a 'range' placeholder for macros in Google Charts/Sheets?
up vote
-1
down vote
favorite
I want to set up a macro that creates and formats a chart based on whatever range I select.
At the moment, because of 'B43:E46' in spreadsheet.getRange( ), the macro produces charts for this particular range.
Is there a place holder I can put here (e.g. $1, $2) that pipes in what ever I have selected (e.g. if I were to select B47:E50)
function createchart1() {
var spreadsheet = SpreadsheetApp.getActive();
spreadsheet.getRange('B43:E46').activate();
var sheet = spreadsheet.getActiveSheet();
var chart = sheet.newChart()
.asColumnChart()
.addRange(spreadsheet.getRange('B43:E46'))
.setMergeStrategy(Charts.ChartMergeStrategy.MERGE_COLUMNS)
.setTransposeRowsAndColumns(false)
.setNumHeaders(-1)
.setHiddenDimensionStrategy(Charts.ChartHiddenDimensionStrategy.IGNORE_BOTH)
.setPosition(31, 1, 170, 111)
.build();
sheet.insertChart(chart);
google-apps-script google-sheets google-sheets-macros
add a comment |
up vote
-1
down vote
favorite
I want to set up a macro that creates and formats a chart based on whatever range I select.
At the moment, because of 'B43:E46' in spreadsheet.getRange( ), the macro produces charts for this particular range.
Is there a place holder I can put here (e.g. $1, $2) that pipes in what ever I have selected (e.g. if I were to select B47:E50)
function createchart1() {
var spreadsheet = SpreadsheetApp.getActive();
spreadsheet.getRange('B43:E46').activate();
var sheet = spreadsheet.getActiveSheet();
var chart = sheet.newChart()
.asColumnChart()
.addRange(spreadsheet.getRange('B43:E46'))
.setMergeStrategy(Charts.ChartMergeStrategy.MERGE_COLUMNS)
.setTransposeRowsAndColumns(false)
.setNumHeaders(-1)
.setHiddenDimensionStrategy(Charts.ChartHiddenDimensionStrategy.IGNORE_BOTH)
.setPosition(31, 1, 170, 111)
.build();
sheet.insertChart(chart);
google-apps-script google-sheets google-sheets-macros
Why not pass the range to the function as a parameter?
– ttarchala
Nov 9 at 15:50
1
Read about theSelection
class in the Apps Script developer reference. @tt macros are called from the spreadsheet via key combo, not via menu or sidebar. While a wrapper that passes the selection to this plotter is a good idea, it isn't critical unless the plot code could also be used by other code in this project
– tehhowch
Nov 10 at 14:50
add a comment |
up vote
-1
down vote
favorite
up vote
-1
down vote
favorite
I want to set up a macro that creates and formats a chart based on whatever range I select.
At the moment, because of 'B43:E46' in spreadsheet.getRange( ), the macro produces charts for this particular range.
Is there a place holder I can put here (e.g. $1, $2) that pipes in what ever I have selected (e.g. if I were to select B47:E50)
function createchart1() {
var spreadsheet = SpreadsheetApp.getActive();
spreadsheet.getRange('B43:E46').activate();
var sheet = spreadsheet.getActiveSheet();
var chart = sheet.newChart()
.asColumnChart()
.addRange(spreadsheet.getRange('B43:E46'))
.setMergeStrategy(Charts.ChartMergeStrategy.MERGE_COLUMNS)
.setTransposeRowsAndColumns(false)
.setNumHeaders(-1)
.setHiddenDimensionStrategy(Charts.ChartHiddenDimensionStrategy.IGNORE_BOTH)
.setPosition(31, 1, 170, 111)
.build();
sheet.insertChart(chart);
google-apps-script google-sheets google-sheets-macros
I want to set up a macro that creates and formats a chart based on whatever range I select.
At the moment, because of 'B43:E46' in spreadsheet.getRange( ), the macro produces charts for this particular range.
Is there a place holder I can put here (e.g. $1, $2) that pipes in what ever I have selected (e.g. if I were to select B47:E50)
function createchart1() {
var spreadsheet = SpreadsheetApp.getActive();
spreadsheet.getRange('B43:E46').activate();
var sheet = spreadsheet.getActiveSheet();
var chart = sheet.newChart()
.asColumnChart()
.addRange(spreadsheet.getRange('B43:E46'))
.setMergeStrategy(Charts.ChartMergeStrategy.MERGE_COLUMNS)
.setTransposeRowsAndColumns(false)
.setNumHeaders(-1)
.setHiddenDimensionStrategy(Charts.ChartHiddenDimensionStrategy.IGNORE_BOTH)
.setPosition(31, 1, 170, 111)
.build();
sheet.insertChart(chart);
google-apps-script google-sheets google-sheets-macros
google-apps-script google-sheets google-sheets-macros
edited Nov 9 at 20:50
TheMaster
8,3273730
8,3273730
asked Nov 9 at 12:34
cget
186
186
Why not pass the range to the function as a parameter?
– ttarchala
Nov 9 at 15:50
1
Read about theSelection
class in the Apps Script developer reference. @tt macros are called from the spreadsheet via key combo, not via menu or sidebar. While a wrapper that passes the selection to this plotter is a good idea, it isn't critical unless the plot code could also be used by other code in this project
– tehhowch
Nov 10 at 14:50
add a comment |
Why not pass the range to the function as a parameter?
– ttarchala
Nov 9 at 15:50
1
Read about theSelection
class in the Apps Script developer reference. @tt macros are called from the spreadsheet via key combo, not via menu or sidebar. While a wrapper that passes the selection to this plotter is a good idea, it isn't critical unless the plot code could also be used by other code in this project
– tehhowch
Nov 10 at 14:50
Why not pass the range to the function as a parameter?
– ttarchala
Nov 9 at 15:50
Why not pass the range to the function as a parameter?
– ttarchala
Nov 9 at 15:50
1
1
Read about the
Selection
class in the Apps Script developer reference. @tt macros are called from the spreadsheet via key combo, not via menu or sidebar. While a wrapper that passes the selection to this plotter is a good idea, it isn't critical unless the plot code could also be used by other code in this project– tehhowch
Nov 10 at 14:50
Read about the
Selection
class in the Apps Script developer reference. @tt macros are called from the spreadsheet via key combo, not via menu or sidebar. While a wrapper that passes the selection to this plotter is a good idea, it isn't critical unless the plot code could also be used by other code in this project– tehhowch
Nov 10 at 14:50
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53225814%2fis-there-a-range-placeholder-for-macros-in-google-charts-sheets%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Why not pass the range to the function as a parameter?
– ttarchala
Nov 9 at 15:50
1
Read about the
Selection
class in the Apps Script developer reference. @tt macros are called from the spreadsheet via key combo, not via menu or sidebar. While a wrapper that passes the selection to this plotter is a good idea, it isn't critical unless the plot code could also be used by other code in this project– tehhowch
Nov 10 at 14:50