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

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
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,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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