I need to do something very simple and straight forward in google sheets. I was able to perform this on Excel, but just haven't resolved it in sheets
I have a sheet with stock figures for printer cartridges. Next to the total of cartridges available i want to add a 'plus' and 'minus' button (i have the buttons in place ready) what i want them to do is add or minus 1 to the figure in the total box. I just cant work out the script at all.
I did it in Excel using the following
Sub Button1_Click()
Range("A1") = Range("A1") + 1
End Sub
But that doesn't work at all in sheets.
Please dont mock me for this, I am a complete new comer to scripting so very much learning the tricks of the trade.
Thanks in advance to anyone who helps
Select the Tools menu and click Script Editor. Copy and paste the following code.
function plus() {
ss=SpreadsheetApp.getActiveSpreadsheet()
s=ss.getActiveSheet()
var currVal=s.getRange("A1").getValue()
var plusVal= currVal +1
s.getRange("A1") .setValue(plusVal)
}
function minus() {
ss=SpreadsheetApp.getActiveSpreadsheet()
s=ss.getActiveSheet()
var currVal=s.getRange("A1").getValue()
var minusVal= currVal -1
s.getRange("A1") .setValue(minusVal)
}
From you sheet right click on the shape (button) and click the arrow. From the menu select Assign Script. Enter plus (for the plus button). This is the function name for the plus function. Repeat for the minus button assigning the minus function.
The first time you run the script you will see two popups. Continue and Accept in the popup windows.
Related
I'm trying to test many result as I add elements to my pipeline so I find a little annoying to add "%>% View" everyhing I need to check for results. Why I don't just select the code I want to view results in a new window? (I know how to use ctrl + enter to run code btw.)
I tried using ctrl and left click but it does not work on pipeline.
I need to get this window to click on the continue button if it pops out when no data is changed and continue with the next cell
You need to use something like this...
Note: you need to change this "wnd[1]/usr/tblSAPLV14ATCTRL_D0102" with the script you recorded.
If Not session.findById("wnd[1]/usr/tblSAPLV14ATCTRL_D0102", False) Is Nothing Then
session.findById("wnd[1]/tbar[0]/btn[24]").press
End If
I want to open a button named 'Open' in IE window using VBScript. Source code is like this:
<a title="Devtems Life Menu" href="javascript:OpenOryx('cboClone');">Open</a>
Before I start answering the question, I just want to say that I am by no means an expert at VBScript. My knowledge is based off a lot of messing around with it during weekends and a bit of read the documentation. There may be better ways of doing things, but this works for me.
My recommendation is if you have access to the html, add an attribute to your link so it looks something like this:
<a title="Devtems Life Menu" href="javascript:OpenOryx('cboClone');" id="openMenu">Open</a>
Then you can easily reference it in your code. If you can't access the html, then you may have to use a more roundabout way of checking the contents of each link. The actual syntax is described below in a little script I constructed. It firstly loads w3schools.com, then clicks on the references tab. This uses ie.document.getElementById(arg). Notice that the references navigation panel opens. After that it will prompt you to click the ok button to continue. It will then load google.com, and look through all the <a> tags. If it contains Open it clicks on it. You can use the same syntax, except different details for your script.
' Create the ie object
set ie = createobject("internetexplorer.application")
' Navigate to wherever you want
ie.navigate("http://www.w3schools.com/")
ie.Visible = true
' Call the subroutine we define below
waitForPage(ie)
' Get link by id
' This is a one liner, and I personally think is better than the method below
' first of all you get the tag you want by id
' then you click it
ie.document.getElementById("navbtn_references").click()
' call ie.document.parentWindow.execScript("w3_open_nav('references')", "JavaScript")
' could also be written as:
'set buttonElement = ie.document.getElementById("navbtn_references")
'buttonElement.click()
MsgBox("Click ok to continue to google.")
' Load google
ie.navigate("https://google.com/")
' And wait for it to load
waitForPage(ie)
' Click on a link by attribute (same technique can be used for name etc)
' Get all elements with tag input
set linkElements = ie.document.getElementsByTagName("a")
' Then loop through them
for each possibleElement in linkElements
' If it has a certain name..
if possibleElement.innerHtml = "About" then ' You could use If possibleElement.getAttribute("name") = "foo" Then or possibleElement.getAttribute("class") = "bar"
' Click it!
possibleElement.click()
end if
next
' Subroutine to wait for internet explorer to load a page
sub waitForPage(ie)
do
WScript.Sleep(100)
loop while ie.ReadyState < 4
end sub
Another method is rather than actually finding and clicking on the link, you simply run the script that is run when a user normally clicks on a link. In your case, it could mean running javascript:OpenOryx('cboClone'); directly. Here is how to run javascript code in VBScrpt:
call ie.document.parentWindow.execScript("javascript:OpenOryx('cboClone');", "JavaScript")
I hope that at least one of these methods helps you in writing your script.
i am using function "REUSE_ALV_GRID_DISPLAY" in order to display a grid. My problem is that not all the buttons in alv toolbar are displayed. For example, i can not see the "delete row" button.
This is my call:
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
IT_FIELDCAT = fieldcatalog
TABLES
t_outtab = lt_files_records_final
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2
.
Can you please help?
IF you need the full editor functionality (including cell editors), you will have to move away from the (obsolete and unsupported) function module to the class CL_GUI_ALV_GRID. See the documentation here.
If you only need a delete button, it might be easier to add a custom button. Check the program SALV_DEMO_TABLE_FUNCTIONS for an example (and start using the ALV OM instead of the old function modules - much easier to code with).
I have created a command button on the Ribbon Toolbar. When I select an component an click on "Display Info" button, an popup should open telling me about the latest version of the Component, Modified date, and the User who last modified it.
I do get the component with the following code:
var item = $models.getItem(selection.getItem(0));
How can I get the other information from here.
Part 2:
When I try to see the JS code in Firebug, I see them in one single line. I am unable to put an break point on the execute function within my code.
Any suggestions on the above points. ?
To deminify the JS, to allow you to add breakpoints, and also to allow you to use a JS console to inspect objects that are available, you can follow the instructions at http://code.google.com/p/tridion-2011-power-tools/wiki/DeactivateJSMinifier.
User information can be retrieved using the information at How to get the user Id of the currently logged user in Tridion?
I find that the only way to find anything with Anguilla is to use a JS Console like Chrome's.
Once you get the current item - like you do now - you can do stuff like:
var version = item.getVersion();
var lastModifiedDate = item.getLastModifiedDate();
var lastEditorId = item.getStaticRevisorId();
getStaticRevisorId() gives you the Tridion URI of the last user to change the item, and you can then load this to retrieve further information from it.