Reputation: 65
I would like by click on a hyperlink in cell A2 to jump to cell B2 and copy the data from cell C2 in B2. Is that possible?
Upvotes: 0
Views: 180
Reputation: 201358
I believe your goal as follows.
For this, how about this answer?
In your case, unfortunately, I think that your goal might noe be able to be achieved with only the built-in function. So I would like to propose to achieve your goal using Google Apps Script. And here, I would like to propose to use the OnSelectionChange event trigger for achieving your goal.
Please create the cell which has the hyperlink to the cell "A2". In this case, the formula of this is as follows. In this case, as a test case, please put the following formula to "C6", and the jumped cell is the same sheet of this formula.
=HYPERLINK("https://docs.google.com/spreadsheets/d/###/edit#gid=###&range=A2","Jump to A2")
If you use this URL, please set the Spreadsheet ID and sheet ID.
Please copy and paste the following script to the script editor of Google Spreadsheet, and save it.
function onSelectionChange(e) {
const range = e.range;
if (range.getA1Notation() == "A2") {
range.offset(0, 2).copyTo(range.offset(0, 1));
}
}
Please click the hyperlink at the cell "C6". By this, the cell "A2" is activated and the function of onSelectionChange
is run by the event trigger. Then, the value of cell "C2" is copied to the cell "B2". The demonstration of this is as follows. In this case, even when the cell "A2" is directly selected, the script works.
Upvotes: 2