Created
May 21, 2021 06:55
-
-
Save dorward/a9863d151a0ace3d5267dcba908fade5 to your computer and use it in GitHub Desktop.
Replaces / with \ in Google Sheets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function onOpen() { | |
const ui = SpreadsheetApp.getUi(); | |
ui.createMenu('Extras') | |
.addItem('Replace / with \\ in selection', 'replaceSlashes') | |
.addToUi(); | |
} | |
function replaceSlashes() { | |
const ss = SpreadsheetApp.getActiveSpreadsheet(); | |
const range = SpreadsheetApp.getActive().getActiveRange(); | |
const numRows = range.getNumRows(); | |
const numCols = range.getNumColumns(); | |
for (let i = 1; i <= numCols; i++) { | |
for (let j = 1; j <= numRows; j++) { | |
const cell = range.getCell(j, i) | |
cell.setValue(cell.getValue().replace(/\//g, "\\")); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment