I want to importxml from more than 50 sites in Google Documents and fill that information into another sheet and preferably overwrite the data already there preventing a clear function. The problem I'm running into however is I'm getting
={229999999.99;0;0;183000000;169999999.99;209999999.99}
in one cell. How do I split this to be six numbers in different columns but the same row?
This is my code:
function Xml() {
var sheet = SpreadsheetApp.getActiveSpreadsheet();
var s = sheet.getSheetByName('Script');
var ss = sheet.getSheetByName('TradeIBuy');
var Num = Browser.inputBox("How many URLs to scrape");
for (y=0;y<2;y++) {
for (x=2;x-2 < Num;x++) {
//ss.getRange("b4:n400").setValue(""); //Too slow for spreadsheet
var url = s.getRange(x,1).getValue(); //Grab URL
s.getRange(2,6).setValue(url); //Move URL into position
var xpathResult = s.getRange("F3:F8").getValues(); //Grab results from first sheet
if (y===1){
var export = ss.getRange(x+2,2); //Export position
export.setValue(xpathResult); //Export data to second sheet
SpreadsheetApp.flush();
}
}
}
}
function clear() {
var sheet = SpreadsheetApp.getActiveSheet();
sheet.getRange("a2:b1000").setValue("");
}
Thanks ~ Chandler
var xpathResult = s.getRange("F3:F8").getValues();
then writing the array to a single cellexport.setValue(xpathResult);
. You want a 1x6 array (aka a row). So, you should transpose the array you've read, then write it to a range usingss.getRange(x+2,2,1,6).setValues()
. See this answer for a function that will do what you are asking. – Mogsdad