VBA - Get Save Path from another sheet

Obwan

Board Regular
Joined
May 14, 2012
Messages
56
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
Using Microsoft 365

VBA File save location.

In a VBA routine I save the DATA output to a file location.

My 1st attempt saved the file successfully by hard coding the path.

Set ws = Worksheets("Data")

custname = Range("B2")

path = "C:\Users\myname\Documents\Test file\excel\"

fname = custname




My 2nd attempt saved the file successfully when I pointed to a cell on the same sheet (DATA).

Set ws = Worksheets("Data")

custname = Range("B2")

path = Range("A1")

fname = custname




What I really want to do, is get path from a cell on a different sheet – Sheet: Header, Cell E2. How do I tell the routine to go to the Header to pick up the path name?
Do you need more infortmation?



Thank you for your help.
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
If you haven't set the different sheet to a variable, then perhaps something like this:

path = Worksheets("Header").Range("E2")
 
Upvote 1
If you haven't set the different sheet to a variable, then perhaps something like this:

path = Worksheets("Header").Range("E2")
Absolutely perfect. Thank you from a VBA newbie
 
Upvote 0

Forum statistics

Threads
1,216,881
Messages
6,133,215
Members
449,789
Latest member
foxsparrow

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