ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Using a cell's value in a macro command (https://www.excelbanter.com/excel-discussion-misc-queries/248963-using-cells-value-macro-command.html)

TomHull

Using a cell's value in a macro command
 
Hi,

I need to use a value of a cell in a spreadsheet in a macro command to copy
data.

For Example.

cell A1 = 28/09/2009

Sub

Workbooks.Open Filename:= _ "C:\(Value from A1)"

End Sub


Thanks,

Tom







FSt1

Using a cell's value in a macro command
 
hi
try something like this.........

Dim r As String
r = Range("A1").Value
Workbooks.Open Filename:= _
"C:\your\file\path\" & r & ".xls"

but in your example data, you have slashes. these are illigal characters in
a file name so i doubt that you have a file with slashes in the name. excel
would have thrown up error messages if you had tried to name a file with
slashes in it. in fact all of the follow characters are
illigal....forbidden.....taboo.....
: / \ * [ ]

regards
FSt1


"TomHull" wrote:

Hi,

I need to use a value of a cell in a spreadsheet in a macro command to copy
data.

For Example.

cell A1 = 28/09/2009

Sub

Workbooks.Open Filename:= _ "C:\(Value from A1)"

End Sub


Thanks,

Tom







TomHull

Using a cell's value in a macro command
 
spot on mate, thanks a lot.

"FSt1" wrote:

hi
try something like this.........

Dim r As String
r = Range("A1").Value
Workbooks.Open Filename:= _
"C:\your\file\path\" & r & ".xls"

but in your example data, you have slashes. these are illigal characters in
a file name so i doubt that you have a file with slashes in the name. excel
would have thrown up error messages if you had tried to name a file with
slashes in it. in fact all of the follow characters are
illigal....forbidden.....taboo.....
: / \ * [ ]

regards
FSt1


"TomHull" wrote:

Hi,

I need to use a value of a cell in a spreadsheet in a macro command to copy
data.

For Example.

cell A1 = 28/09/2009

Sub

Workbooks.Open Filename:= _ "C:\(Value from A1)"

End Sub


Thanks,

Tom








All times are GMT +1. The time now is 04:37 AM.

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