VBA – Copying and pasting data from one document to another
Hello VBA experts,
Running Excel 365. A little bit of context:
I have an original Excel file named CBD Original. In this file, there is a range (B10:B25) with product references. For each reference that is “NE” and/or “N” my code opens the other excel file that is located in the same folder as the current Excel file and that is named “PBD Cliente”, pastes data from CBD Original file based on some ranges that simulate the two different tabs of the PBD file and finally saves a copy of it.
I have already played around with the code in order to create this functionality. All you have to do is to put both attached files in a folder, open the CBD Original file and then run the macro.
The problem is the following: PBD file has its sheets protected. Specifically, blue “columns” are locked and values cannot be entered in those cells. I already know that (note that blue “columns” in the CBD Original file are empty because I know I should not paste any values there) but I do not know how to rearrange the code in order to understand that. As per now, the code simply copies row by row entirely and tries to paste it on the other file, which results breaking the whole automation because certain cells cannot be pasted (even if they are already blank). Run-time error 1004 occurs.
The attached PBD file does not have its sheet protected so that you can see the functionality working correctly. Please protect its sheets and make sure only blue columns are the ones unable to receive data when trying to propose a solution.
I hope anyone could give me a hand with this.
Martin
Hello VBA experts, Running Excel 365. A little bit of context: I have an original Excel file named CBD Original. In this file, there is a range (B10:B25) with product references. For each reference that is “NE” and/or “N” my code opens the other excel file that is located in the same folder as the current Excel file and that is named “PBD Cliente”, pastes data from CBD Original file based on some ranges that simulate the two different tabs of the PBD file and finally saves a copy of it. I have already played around with the code in order to create this functionality. All you have to do is to put both attached files in a folder, open the CBD Original file and then run the macro. The problem is the following: PBD file has its sheets protected. Specifically, blue “columns” are locked and values cannot be entered in those cells. I already know that (note that blue “columns” in the CBD Original file are empty because I know I should not paste any values there) but I do not know how to rearrange the code in order to understand that. As per now, the code simply copies row by row entirely and tries to paste it on the other file, which results breaking the whole automation because certain cells cannot be pasted (even if they are already blank). Run-time error 1004 occurs. The attached PBD file does not have its sheet protected so that you can see the functionality working correctly. Please protect its sheets and make sure only blue columns are the ones unable to receive data when trying to propose a solution. I hope anyone could give me a hand with this. Martin Read More