A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Excel » General Discussion
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Using a cell's value in a macro command



 
 
Thread Tools Display Modes
  #1  
Old November 20th, 2009, 05:21 AM posted to microsoft.public.excel.misc
TomHull
external usenet poster
 
Posts: 6
Default 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






  #2  
Old November 20th, 2009, 06:32 AM posted to microsoft.public.excel.misc
FSt1
external usenet poster
 
Posts: 2,788
Default 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






  #3  
Old November 20th, 2009, 07:45 AM posted to microsoft.public.excel.misc
TomHull
external usenet poster
 
Posts: 6
Default 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






 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


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


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.