I have a large amount of data that reference cells. I want to lock these references without going into each cell to change the equation. I know there is a way to do a script in excel. I don't know if there is a way to create the same type of script in excel.
Those interested in the excel script:
Sub test()
Dim c As Range
For Each c In Selection
c.Formula = Application.ConvertFormula(c.Formula, xlA1, , xlAbsolute)
Next
End Sub
Thanks Guys!!
There is no Spreadsheet Service method that is equivalent to VBA's Application.ConvertFormula().
You could enter a feature request on the Google Apps Script Issue Tracker. If you do, add a comment here to let us know the issue number.
Related
I'm a complete newbie to programming but wants to learn how. What I did is, I created a google form with 8 questions and the responses goes to a spreadsheet. Now what I want to do is to add another column on the spreadsheet, like a unique ID(should be a sequence like 10001, 10002, 10003, etc.) so I have a unique modifier, in that way once the form is submitted, that unique ID, will also increment by 1.
So far what I did is I created an array on the spreadsheet Unique ID column with this formula:
=arrayformula(if(row(A2:A)=1,"Unique ID",if(len(A2:A)>0,9999+row(A2:A),iferror(1/0))))
But, I don't know how to call the value on the google script editor. (example cell: I2 the value is 10001, I3 = 10002). Can you anyone help me with this please? Any help will be appreciated.
Getting your Id from the Form's Linked Sheet
function onFormSubmit(e) {
if(e.values && !e.values[1])return;//make question one a required question. This will keep you from sending emails due to spurious triggers.
var colnum='enter the column number of you id';//A=1,B=2...
var id=e.range.getSheet().getRange(e.range.rowStart,colnum).getDisplayValue();
}
Please note: You can not run a function like this from the Script Editor so to avoid the inevitable question I'll simply point out that this requires a trigger to test it. Or you have to figure out a way to provide it with an event object.
onFormSubmit Event Object
I have a running parts order list that several people use. I am trying to have the top row be a form so the user enters Qty, Part #, and Notes and presses Enter. I want it to add a row to the top of the sheet below the headers and maintain the table structure so we can filter.
Instead of using the top row, go to Tools then create form. This will make it easier to input stuff. Also no one can muck up your sheet.
Also I would read what you can post here :) I like to be friendly so I thought I'd put an answer
You should read about Google Apps Script. GAS is the easiest way to read/write data in Google Spreadsheet/Docs/Forms.
So as far as I understand from your question, you need to insert a row in Google Spreadsheet below the header directly as soon as the forms.
Step 1: Open the spreadsheet using openById(id)
Step 2: Get the worksheet in which you want to save your Google Forms data using getSheetByName(name)
Step 3: Insert row before specified position using insertRowBefore(beforePosition)
So final code should look like this.
var spreadsheet = SpreadsheetApp.openById("1BZuYFCnN_g9vn5crxbPeYlhUKwH6N3u0uT8LCmm-neM");
var sheet = spreadsheet.getSheetByName("Nov-2017");
sheet.insertRowsBefore(2);
The code above will insert only one row below spreadsheet headers. There is an alternative -> insertRowsBefore(beforePosition, howMany) if you want to insert multiple rows at a specified position.
Try this and let me know if you find any difficulties. Hope this is what you're looking for.
I have a small query regarding automatic formula value calculation in excel.
In my project I will be having 200 questions and corresponding 200 answers( numerical values of 10,20 and 30). Those questions and answers are obtained from webpages and all the questions and answers are stored in my sql database. I will collect the answers that are posted in mysql database to excel with the help of mysql add-in.
My question is I have some formulas
given in my excel sheet ex:mean(C204), STDEV(C205), final risk( my own formula F209)
I want the formulas to automatically calculate the formula values whenever I import the
data from mysql. Is it possible in excel if not is there any alternative? Please help!
This is kind of a stab in the dark since I'm not at all familiar with the add in or how it operates. It seems odd that it would import data and not allow a application.calculate event to take place after import.
Perhaps... you can run the application.calculate method on worksheet change. In your VBE, double click the worksheet upon which the mysql data is dropped. Then add this code to that worksheet:
Private Sub Worksheet_Change(ByVal Target As Range)
Application.Calculate
End Sub
There's fairly good chance that the add in also snuffs events by setting application.enableEvents = false which means this won't work, but... it's worth a shot.
How to reference the same (row,column) on the different tab in the same google spreadsheet document?
So, I want to do something like this:
=SOME_FORMULA('First tab'!(ADDRESS(ROW(),COLUMN()))). This doesn't work.
If the formula isn't apsolutly referenced, entries of Google Forms questionnaire change the reference and mess up the formula. (the formula that looked at row number 5 after insert looks at row number 6) I can't use apsolute referencing ($A$1) because I have to enter it manually.
Can I change the reference on multiple cells? (for one I can use cmd + f4)
I had that annoying reference problem too. If I understand correctly you are trying to get the information on some cells, but every time someone sends information to the spreadsheet by filling up a Form, that reference moves down a row.
The best solution I came up with was to create a new SpreadSheet and import all the information with this:
=importrange("spreadsheet-key","Form Responses!A1:B2107")
That function updates the info in realtime, so you can do all the processing on the new spreadsheet.
Hope this helps.
Do not quite understand what you need. Need to reference a cell in another sheet given coordinates on the current cell where it is located?
If so, the following formula can be useful:
=INDIRECT("First tab!"&ADDRESS(ROW(), COLUMN()))
I am trying to put conditional formula in spreadsheet using google apps script but i am not getting the way out to resolve this.
The VBA equivalent to the required GAS is:
Sub ageing()
Rem Ageing Slabs for ADVANCES
With Range("ap2:ap4000")
.Formula = "=IF(u2="""","""",if(u2<0,""Delivery Reported after
RC"",IF(AND(u2>=0,u2<31),""Ageing
0-30"",IF(AND(u2>=31,u2<=60),""Ageing
31-60"",IF(AND(u2>=61,u2<=90),""Ageing
61-90"",IF(AND(u2>=91,u2<=120),""Ageing
91-120"",IF(and(u2>120,u2<=180),""Ageing 121-180"",IF(u2>180,""More
than 6 months"",""""))))))))"
.Value = .Value
End With
End Sub
Kindly suggest the VBA equivalent to this in GAS.
Thanks
The same question posted on https://productforums.google.com/forum/#!category-topic/docs/spreadsheets/how-do-i/desktop/H2dXGR7arvU
You can use Range.setFormula() to set a formula in a cell.
SpreadsheetApp.getActiveRange().setFormula('=SUM(A1:A100)');
I think you can make it less complicated by not checking twice for each condition
In JS you can put single quotes and double quotes inside it, or " and \" inside.
You can use ArrayFormula for this type of tasks, and you can even eliminate Google Apps Script or VBA (it's just one formula in the end)
SpreadsheetApp.getRange("AP2").setFormula('IF(U2:U4000="","",IF(U2:4000<0,"Delivery Reported after RC",IF(U2:U4000<=30,"Ageing 0-30",IF(U2:U4000<=60,"Ageing 31-60",IF(U2:U4000<=90,"Ageing 61-90",IF(U2:U4000<=120,"Ageing 91-120",IF(U2:U4000<=180,"Ageing 121-180","More than 6 months","")))))))');