ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Replacing hard code with reference to a cell value (https://www.excelbanter.com/excel-programming/324680-replacing-hard-code-reference-cell-value.html)

jojo

Replacing hard code with reference to a cell value
 
Hello,

Currently I am using the following line of code to specify the location of
my database.

MyConn = "S:\Mydatabase.mdb"

Instead of hard coding the location of my database, I would like to enter
the location in Cell A1 in Sheet2. How do I change this line of code so it
would read the location of my database from whatever I type into cell A1 in
Sheet2?

Thanks!

Dave Peterson[_5_]

Replacing hard code with reference to a cell value
 
myConn = activeworkbook.worksheets("sheet2").range("a1").va lue

Activeworkbook
could be
ThisWorkbook
if the that worksheet is in the same workbook with the code.

Or even
workbooks("myotherworkbook.xls").worksheets("sheet 2").range("a1").value



jojo wrote:

Hello,

Currently I am using the following line of code to specify the location of
my database.

MyConn = "S:\Mydatabase.mdb"

Instead of hard coding the location of my database, I would like to enter
the location in Cell A1 in Sheet2. How do I change this line of code so it
would read the location of my database from whatever I type into cell A1 in
Sheet2?

Thanks!


--

Dave Peterson

jojo

Replacing hard code with reference to a cell value
 
thank you!

"Dave Peterson" wrote:

myConn = activeworkbook.worksheets("sheet2").range("a1").va lue

Activeworkbook
could be
ThisWorkbook
if the that worksheet is in the same workbook with the code.

Or even
workbooks("myotherworkbook.xls").worksheets("sheet 2").range("a1").value



jojo wrote:

Hello,

Currently I am using the following line of code to specify the location of
my database.

MyConn = "S:\Mydatabase.mdb"

Instead of hard coding the location of my database, I would like to enter
the location in Cell A1 in Sheet2. How do I change this line of code so it
would read the location of my database from whatever I type into cell A1 in
Sheet2?

Thanks!


--

Dave Peterson



All times are GMT +1. The time now is 05:10 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com