double click copy contents of adjacent cell

143 views
Skip to first unread message

Picloan Limited

unread,
Jul 25, 2021, 5:27:21 AM7/25/21
to Google Apps Script Community

Please help me, I need a simple code which will copy contents of adjacent left cell when I double click cell and paste the value to a cell in another  sheet. This is to help me in making entries as reference.

If I click c2 it should copy value  from b2 and paste it in A8 of another sheet, and it should do it for c2: c


var ss = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Sheet1");

var cell = ss.getRange();

var sh = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("SHEET8");


If Cell.CountLarge > 1 Then Exit

If Not Intersect(cell.Range("C2:C100")) Is Nothing Then

Cancel = True
cell.Value = cell.Offset(, -1).Value

ss.copyTo (sh.getRange ("A8 '), {contentsOnly: true});

Clark Lind

unread,
Jul 25, 2021, 11:54:54 AM7/25/21
to Google Apps Script Community
I don't think Sheets has that level of programing available. To change the behavior of a Double-click is to change the behavior of the operating system, not Sheets. Instead, you could do what you want with short-cut keys. 

Picloan Limited

unread,
Jul 25, 2021, 4:26:10 PM7/25/21
to google-apps-sc...@googlegroups.com
hmmmm. Thanks

--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/42033d8e-617d-471b-bc9c-b63589d4c219n%40googlegroups.com.

Michael O'Shaughnessy

unread,
Jul 25, 2021, 4:31:23 PM7/25/21
to google-apps-sc...@googlegroups.com
I do believe @Clark is correct.  "Double clicks" are an operating system event.  But Clark gave me an idea....  use a MACRO and add a shortcut!!  OR create a trigger that when "C2" is edited it does what you want.

So, I guess I am asking as to why you want the "double click"?  Is it to make it easier for the user?  If that is the case, you could insert a column after C and fill it with checkboxes.  Create a trigger that runs when the checkbox is checked to do what you want.

Thoughts?

--

Picloan Limited

unread,
Jul 25, 2021, 5:05:06 PM7/25/21
to google-apps-sc...@googlegroups.com
if it is possible,client will click on total but copy figure will be  use again to generate detail of the total

Michael O'Shaughnessy

unread,
Jul 25, 2021, 6:06:15 PM7/25/21
to google-apps-sc...@googlegroups.com
Here is an example spreadsheet that has checkboxes.  You check the box and it copies what is in column A to cell D8 on Sheet2.

Hope this helps...

Reply all
Reply to author
Forward
0 new messages