VBA Userpath help

Deda2022

New Member
Joined
Feb 16, 2022
Messages
2
Office Version
  1. 365
Platform
  1. Windows
  2. Web
I have a macro (assigned to a button in a worksheet) that saves a filtered worksheet to the user’s desktop. The userpath for the user has recently changed. I have not been able to revise my code properly go to the new location.

The previous code was:

Dim userpath As String

Dim acell2 As String

acell = Replace(acell, “/”, “”)

userpath = Environ(“UserProfile”) & “\Desktop\” & acell & “.xlsb”

ActiveWorkbook.SaveAs Filename:=userpath, FileFormat:=xlExcel12

ActiveWorkbook.Close

Application.Workbooks(“2022 SPD Tracker”).Activate


The new path, however, is:

C:\Users\CottoLis\OneDrive – CompanyName\Desktop

What am I missing?

Thanks in advance!!

Lisa
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
does the user press the button to run the code or you?
If its the user then you could use ThisWorkbook.path or ThisWorkbook.fullname
 
Upvote 0

Forum statistics

Threads
1,214,983
Messages
6,122,583
Members
449,089
Latest member
Motoracer88

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