Can formulas have the Windows Username in them?

RockandGrohl

Well-known Member
Joined
Aug 1, 2018
Messages
671
Office Version
  1. 2010
Platform
  1. Windows
Hello hello, a non-VBA question for once.

A macro opens a spreadsheet, which is chock full of pre-existing formulas. These formulas USED TO reference a static location on our server that everyone had the same link to.

We've since moved to OneDrive, so everyones file path is now like... "C:\Users\RockandGrohl\Server\DestinationFile\Answer.xlsx"

Therefore, if I change the link in the sheet to the above string, it will only work when I open the file. So if user "Mike" runs the macro, which opens that Answer.xlsx file, the formulas will point towards RockandGrohl's file which is obviously on his PC (but the file does exist on Mike's PC, via OneDrive, just under a different path.


So is it easier to

A) Do a mass find and replace which has a dynamic username?
B) Change the links via VBA using the clever Environ("username") function?


Cheers!
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple

earthworm

Well-known Member
Joined
May 19, 2009
Messages
622
Office Version
  1. 2019
  2. 2016
Platform
  1. Windows
Use this function in sheet to get the username
=INFO("DIRECTORY")
remove unnecessary info and then point the Macro directory to that specific cell to make it dynamic for every user.
 

Forum statistics

Threads
1,148,173
Messages
5,745,183
Members
423,931
Latest member
thangvan114

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
Top