Select values from spreadsheet and use as strings

  • Thread starter Thread starter sean_f
  • Start date Start date
S

sean_f

Hello,
I currently have a number of strings which are declared as hard code in
the macro
for example
dim folderloc as String
folderloc = "C:\Development\filename.xls"

I would like to look this up from a cell in the workbook.
So that
Sheet1 A1 would have the value
C:\Development\filename.xls

and this would be passed to my code

How would I do this.


Many Thanks

Sean
 
i am assuming you want to open the file

Workbooks.Open Filename:=Range("A1").Value, _
ReadOnly:=True, UpdateLinks:=3
 
dim folderloc as string
folderloc=Worksheets("Sheet1").Range("A1").Value

For better readability you could name ("FolderLocation") your range, in
which case you could use:
folderloc=Range("FolderLocation").Value

HTH
 
forgot to qualify the sheet

Workbooks.Open Filename:=Sheets("Sheet1").Range("A1").Value, _
ReadOnly:=True, UpdateLinks:=3
or this

Dim fname As String
fname = Sheets("sheet1").Range("a1")
Workbooks.Open Filename:=fname, _
ReadOnly:=True, UpdateLinks:=3
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top