VBA to save a sheet in shared Onedrive folder

Kine

New Member
Joined
Apr 23, 2023
Messages
2
Office Version
  1. 365
Platform
  1. Windows
  2. Web
Hi Everyone.

I have an Excel file with many sheets stored in my Onedrive. I would like to select a specific sheet of that Exel file and save it as a new Excel file in a shared folder of my Onedrive. I would like other users (with different Onedrive accounts) to access the file from the shared folder and to be able to use it. Also, I would like to do this often so the old shared file need to be replaced by the new one (containing extra data) instead of the code creating a new file.
I think this has 4 main challenges:
- Make the file accessible to users with different Onedrives from any device (no local path I think)
- Enable me to replace the existing file without the vba code asking " are you sure"
- Initially close any file that would contain the same name as my shared file so that any "saveas" function would work with no issue


Could someone kindly help me with the code that would do this? I am not a VBA expert but I can adapt an existing code.

Many thanks
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
Use the Excel Macro Recorder to record yourself performing the action of selecting a worksheet from you master file, copying it to a new workbook, then saving the new workbook to your OneDrive folder you have described above. Then post the code generated by the macro recorder here and we will see if it is possible to automate it to make it more broadly applicable.

 
Upvote 0
Thank you very much. Actually I never knew this recorder existed. I will look to see how it works. Thanks
 
Upvote 0

Forum statistics

Threads
1,223,885
Messages
6,175,182
Members
452,615
Latest member
bogeys2birdies

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top