delete that, use this
let rng1 = selectedSheet.getRange("B3").getValue();
selectedSheet.getRange("C16").setValue(rng1);
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I created a simple recorded-action macro in excel designed to pull key data from specific cells after the contents of a .txt file data are pasted into a specific location (with text to columns active for space, tab, and forward-slash, treating consecutive delimiters as one) and the macro is run. After pasting the data into the spreadsheet, all it does is copy and paste cells one at a time to reorganize the data. It was working yesterday, but not today.
Here's the code, and the error:
function main(workbook: ExcelScript.Workbook) {
let selectedSheet = workbook.getActiveWorksheet();
// Paste to range B3 on selectedSheet from range C16 on selectedSheet
selectedSheet.getRange("B3").copyFrom(selectedSheet.getRange("C16"), ExcelScript.RangeCopyType.all, false, false);
Line 4: Range copyfrom: You cannot perform the requested operation.
There is no error code associated and the help options are unrelated to the issue
Troubleshooting I've tried that have failed:
-Closing and reopening Excel
-Pasting the data as values
-Deleting potentially problematic steps in the macro function
-Re-recording the steps of the macro
-Reverting to an older version of the file and using data files that worked
[I feel like I've tried everything besides creating a range of calculated cells to clone the data and then copying and pasting the values from that] EDIT: this did not work either.
I suspect the recent Microsoft update (5/28) is the cause, either changing the way text-to-columns works and causing consecutive delimiters to be formatted as merged cells OR they broke the way macros handle copy-and-paste functions. My company IT department pushes all updates automatically and requires them, so I do not have the option to revert to an older version if that is the only fix.
Any help would be greatly appreciated. Please bear in mind that I am not working with VBA, just recorded actions. My skills with coding are still limited.
delete that, use this
let rng1 = selectedSheet.getRange("B3").getValue();
selectedSheet.getRange("C16").setValue(rng1);
Hi,
It's possible that recent updates to Excel could have introduced changes that affect the recorded macro's functionality.
Ensure that your Excel application and the recorded macro are compatible. Verify that the recorded macro was created in the same version of Excel that you're currently using.
Test with Manual Steps:
Best Regards.
I still cannot get the macro to work, as of 6/1/2023, however I did find a simplistic workaround. If you can't copy and paste data with a macro, the only solution that works for me seems to be cell-reference formulas that clone the data. While it does cut down very slightly on software load, the cons to using cell references are apparent:
I am having the same issue. I tried recording the macro again today and I am still getting an error on line 4: Range copyfrom: You cannot perform the requested operation.
All other macros with the same script are running fine
Hi everyone, thanks for reporting this issue! The Office Scripts team is investigating and we have confirmed that scripts are failing more often than usual on Excel for Windows, specifically builds 16.0.16327.20308 and 16.0.16501.20196. We are currently trying to reproduce the issue and determine the underlying cause.
In the meantime, you can try the following workarounds:
Additionally, if you continue to encounter this issue, let us know - understanding what specific APIs/scenarios are failing can help us identify the root cause. We apologize for the inconvenience; I'll share further updates once we know more!
Update (6/12): this should be fixed in CC and will be fixed soon for MEC and SAC as well. Thank you for your patience!