Skip to content

Get active sheet modification #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Lib.gs
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ function GetSheets(spreadsheet)
function GetActiveSheet(sheetname) {
var sheet;

if (sheetname == '') {
sheet = SpreadsheetApp.getActive().getActiveSheet();
} else {
if (sheetname) {
sheet = SpreadsheetApp.getActive().getSheetByName(sheetname);
} else {
sheet = SpreadsheetApp.getActive().getActiveSheet();
}
return sheet;
}
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ function GetSheets(spreadsheet)

## Get Active Sheet

`GetActiveSheet` function used to get the active OR specific sheet of spreadsheet. it takes `sheetname` as input argument. in case if `sheetname` passed as blank string, it returns active sheet, otherwise it return the sheet provided as `sheetname`
`GetActiveSheet` function used to get the active OR specific sheet of spreadsheet. it takes `sheetname` as input argument. in case if `sheetname` argument is not provided, it returns active sheet, otherwise it return the sheet provided as `sheetname`

We had need of get instance of Current Sheet and in some cases Specific Sheet. so we created a parameterized function that served purpose. To get the Current Active Sheet we can simply use this function with empty sting ('') and in case to get Specific Sheet we can simply use sheet name.
We had need of get instance of Current Sheet and in some cases Specific Sheet. so we created a parameterized function that served purpose. To get the Current Active Sheet we can simply use this function with no argument () and in case to get Specific Sheet we can simply use sheet name.

```javascript
/**
Expand All @@ -73,10 +73,10 @@ We had need of get instance of Current Sheet and in some cases Specific Sheet. s
function GetActiveSheet(sheetname) {
var sheet;

if (sheetname == '') {
sheet = SpreadsheetApp.getActive().getActiveSheet();
} else {
if (sheetname) {
sheet = SpreadsheetApp.getActive().getSheetByName(sheetname);
} else {
sheet = SpreadsheetApp.getActive().getActiveSheet();
}
return sheet;
}
Expand Down