Skip to content
Advertisement

Google Script to copy the values of a column and insert a new column in spreadsheet

I have started creating a spreadsheet to monitor some results from facebook, youtube etc… A lot of things I did I was able to learn from previous answers on this site.

Now I am stuck with trying to find a script which can help me do the following:

Column A contains the description of the metric
Column B contains the formula which pulls the metric from extrenal sources (e.g. number of likes of my facbeook page, number of video views of my YT channel)

I would like to have a script which runs every Monday and performs the following actions:

  1. Insert a new column between column B and column C (moving all columns after B down by 1 place)
  2. Copy column B and paste only the values (not the formulas) in the new empty column C
  3. Write something like Week Commencing YYYY/MM/DD on top of Column C (C1) where YYYY/MM/DD is the date of the previous week’s monday

I have tried a modified version of this (from http://www.kraukoblog.com/marketing/tutorial-watch-your-competitors-facebook-pages-with-google-docs/):

JavaScript

But it only writes the date in the column.

This would enable me to compare the weekly changes in those metrics.

Is this possible at all?

Advertisement

Answer

I have been able to find the solution by navigating through different tutorials on google’s developers page. This is the function I have created

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement