Excel Office Script - Getting data from one cell to another

Mark 0 Reputation points
2023-06-27T15:22:44.0833333+00:00

I'm currently working on a basic setup in excel. Simplified version is that I have two columns (A and B) of numbers. I want to store the data from cell A2 to a variable and set cell D2 to the value of whatever is store in my variable. I tried the following:

let selectedSheet = workbook.getActiveWorksheet();

let Apple = selectedSheet.getRange("A2");

selectedsheet.getRange("D2").setValue("25");

console.log(Apple.getValue()):

That changed cell D2 to 25 and the console log reads the correct value of my test Apple. I then try building off that using the following, but run into issues:

let selectedSheet = workbook.getActiveWorksheet();

let Apple = selectedSheet.getRange("A2");

selectedsheet.getRange("D2").setValue(Apple);

console.log(Apple.getValue()):

It just keeps running indefinitely. Am I trying to set the value wrong?

Microsoft 365 and Office Development Office JavaScript API
Microsoft 365 and Office Development Other
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.