How to make a loop script for Google sheet?
up vote
3
down vote
favorite
I wanted to have a script that will change text to a hyperlink using script. I have column D in Google sheet from D1:D, for example:
12346
34566
23456
23455... and so on...
Currently, I'm using this script, this is for a specific tab named Sheet1
only.
function makeLink() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var aCell = ss.getRange("D1"), value = aCell.getValue();
aCell.setValue('=HYPERLINK("https://sellercentral.amazon.com/hzefad/orders/&orderId='+value+'","'+value+'")');
var aCell = ss.getRange("D2"), value = aCell.getValue();
aCell.setValue('=HYPERLINK("https://sellercentral.amazon.com/hzefad/orders/&orderId='+value+'","'+value+'")');
var aCell = ss.getRange("D3"), value = aCell.getValue();
aCell.setValue('=HYPERLINK("https://sellercentral.amazon.com/hzefad/orders/&orderId='+value+'","'+value+'")');
var aCell = ss.getRange("D4"), value = aCell.getValue();
aCell.setValue('=HYPERLINK("https://sellercentral.amazon.com/hzefad/orders/&orderId='+value+'","'+value+'")');
var aCell = ss.getRange("D5"), value = aCell.getValue();
}
Is there a way to to use looping for me to shorten my script?
javascript
add a comment |
up vote
3
down vote
favorite
I wanted to have a script that will change text to a hyperlink using script. I have column D in Google sheet from D1:D, for example:
12346
34566
23456
23455... and so on...
Currently, I'm using this script, this is for a specific tab named Sheet1
only.
function makeLink() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var aCell = ss.getRange("D1"), value = aCell.getValue();
aCell.setValue('=HYPERLINK("https://sellercentral.amazon.com/hzefad/orders/&orderId='+value+'","'+value+'")');
var aCell = ss.getRange("D2"), value = aCell.getValue();
aCell.setValue('=HYPERLINK("https://sellercentral.amazon.com/hzefad/orders/&orderId='+value+'","'+value+'")');
var aCell = ss.getRange("D3"), value = aCell.getValue();
aCell.setValue('=HYPERLINK("https://sellercentral.amazon.com/hzefad/orders/&orderId='+value+'","'+value+'")');
var aCell = ss.getRange("D4"), value = aCell.getValue();
aCell.setValue('=HYPERLINK("https://sellercentral.amazon.com/hzefad/orders/&orderId='+value+'","'+value+'")');
var aCell = ss.getRange("D5"), value = aCell.getValue();
}
Is there a way to to use looping for me to shorten my script?
javascript
add a comment |
up vote
3
down vote
favorite
up vote
3
down vote
favorite
I wanted to have a script that will change text to a hyperlink using script. I have column D in Google sheet from D1:D, for example:
12346
34566
23456
23455... and so on...
Currently, I'm using this script, this is for a specific tab named Sheet1
only.
function makeLink() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var aCell = ss.getRange("D1"), value = aCell.getValue();
aCell.setValue('=HYPERLINK("https://sellercentral.amazon.com/hzefad/orders/&orderId='+value+'","'+value+'")');
var aCell = ss.getRange("D2"), value = aCell.getValue();
aCell.setValue('=HYPERLINK("https://sellercentral.amazon.com/hzefad/orders/&orderId='+value+'","'+value+'")');
var aCell = ss.getRange("D3"), value = aCell.getValue();
aCell.setValue('=HYPERLINK("https://sellercentral.amazon.com/hzefad/orders/&orderId='+value+'","'+value+'")');
var aCell = ss.getRange("D4"), value = aCell.getValue();
aCell.setValue('=HYPERLINK("https://sellercentral.amazon.com/hzefad/orders/&orderId='+value+'","'+value+'")');
var aCell = ss.getRange("D5"), value = aCell.getValue();
}
Is there a way to to use looping for me to shorten my script?
javascript
I wanted to have a script that will change text to a hyperlink using script. I have column D in Google sheet from D1:D, for example:
12346
34566
23456
23455... and so on...
Currently, I'm using this script, this is for a specific tab named Sheet1
only.
function makeLink() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var aCell = ss.getRange("D1"), value = aCell.getValue();
aCell.setValue('=HYPERLINK("https://sellercentral.amazon.com/hzefad/orders/&orderId='+value+'","'+value+'")');
var aCell = ss.getRange("D2"), value = aCell.getValue();
aCell.setValue('=HYPERLINK("https://sellercentral.amazon.com/hzefad/orders/&orderId='+value+'","'+value+'")');
var aCell = ss.getRange("D3"), value = aCell.getValue();
aCell.setValue('=HYPERLINK("https://sellercentral.amazon.com/hzefad/orders/&orderId='+value+'","'+value+'")');
var aCell = ss.getRange("D4"), value = aCell.getValue();
aCell.setValue('=HYPERLINK("https://sellercentral.amazon.com/hzefad/orders/&orderId='+value+'","'+value+'")');
var aCell = ss.getRange("D5"), value = aCell.getValue();
}
Is there a way to to use looping for me to shorten my script?
javascript
javascript
edited Nov 10 at 20:56
FrankerZ
15.4k72859
15.4k72859
asked Nov 10 at 19:07
Franc
233
233
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
1
down vote
accepted
You can use something like this:
i = 1
while (true) {
var range = ss.getRange("D" + i);
var value = range.getValue();
if(value == "") {
break;
}
range.setValue('=HYPERLINK("https://sellercentral.amazon.com/hzefad/orders/&orderId='+value+'","'+value+'")');
i++;
}
Awesome! This works perfectly to me Martin!. Thank you. You're the best!
– Franc
Nov 10 at 22:07
You're welcome Franc, glad I could help you. Can you please mark the answer as "Accepted" please?
– Martin Urbanec
Nov 10 at 22:14
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
You can use something like this:
i = 1
while (true) {
var range = ss.getRange("D" + i);
var value = range.getValue();
if(value == "") {
break;
}
range.setValue('=HYPERLINK("https://sellercentral.amazon.com/hzefad/orders/&orderId='+value+'","'+value+'")');
i++;
}
Awesome! This works perfectly to me Martin!. Thank you. You're the best!
– Franc
Nov 10 at 22:07
You're welcome Franc, glad I could help you. Can you please mark the answer as "Accepted" please?
– Martin Urbanec
Nov 10 at 22:14
add a comment |
up vote
1
down vote
accepted
You can use something like this:
i = 1
while (true) {
var range = ss.getRange("D" + i);
var value = range.getValue();
if(value == "") {
break;
}
range.setValue('=HYPERLINK("https://sellercentral.amazon.com/hzefad/orders/&orderId='+value+'","'+value+'")');
i++;
}
Awesome! This works perfectly to me Martin!. Thank you. You're the best!
– Franc
Nov 10 at 22:07
You're welcome Franc, glad I could help you. Can you please mark the answer as "Accepted" please?
– Martin Urbanec
Nov 10 at 22:14
add a comment |
up vote
1
down vote
accepted
up vote
1
down vote
accepted
You can use something like this:
i = 1
while (true) {
var range = ss.getRange("D" + i);
var value = range.getValue();
if(value == "") {
break;
}
range.setValue('=HYPERLINK("https://sellercentral.amazon.com/hzefad/orders/&orderId='+value+'","'+value+'")');
i++;
}
You can use something like this:
i = 1
while (true) {
var range = ss.getRange("D" + i);
var value = range.getValue();
if(value == "") {
break;
}
range.setValue('=HYPERLINK("https://sellercentral.amazon.com/hzefad/orders/&orderId='+value+'","'+value+'")');
i++;
}
answered Nov 10 at 20:54
Martin Urbanec
2818
2818
Awesome! This works perfectly to me Martin!. Thank you. You're the best!
– Franc
Nov 10 at 22:07
You're welcome Franc, glad I could help you. Can you please mark the answer as "Accepted" please?
– Martin Urbanec
Nov 10 at 22:14
add a comment |
Awesome! This works perfectly to me Martin!. Thank you. You're the best!
– Franc
Nov 10 at 22:07
You're welcome Franc, glad I could help you. Can you please mark the answer as "Accepted" please?
– Martin Urbanec
Nov 10 at 22:14
Awesome! This works perfectly to me Martin!. Thank you. You're the best!
– Franc
Nov 10 at 22:07
Awesome! This works perfectly to me Martin!. Thank you. You're the best!
– Franc
Nov 10 at 22:07
You're welcome Franc, glad I could help you. Can you please mark the answer as "Accepted" please?
– Martin Urbanec
Nov 10 at 22:14
You're welcome Franc, glad I could help you. Can you please mark the answer as "Accepted" please?
– Martin Urbanec
Nov 10 at 22:14
add a comment |
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%2f53242456%2fhow-to-make-a-loop-script-for-google-sheet%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