Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Need macro to open a variable filename

I have a variable filename in a cell. The cell, K6, contains "
concatenate(K4,H4)"
I recorded a macro that opens "filename" using
Workbooks.Open FileName:= "filename"
but the filename is hard coded as the name when the macro was recorded, not
a variable name. How do I get the macro to open the variable filename in K6?
I am not a VB programmer.

I tried Workbooks.Open FileName:= (K6) but either it isn't the right way
to do it or the syntax is bad.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,119
Default Need macro to open a variable filename

Try

Workbooks.Open FileName:= Sheets("Sheet 1").Range("K6").value

Where "Sheet 1" is the tab name of the sheet containing the file name.
--
HTH...

Jim Thomlinson


"Steve@ABS" wrote:

I have a variable filename in a cell. The cell, K6, contains "
concatenate(K4,H4)"
I recorded a macro that opens "filename" using
Workbooks.Open FileName:= "filename"
but the filename is hard coded as the name when the macro was recorded, not
a variable name. How do I get the macro to open the variable filename in K6?
I am not a VB programmer.

I tried Workbooks.Open FileName:= (K6) but either it isn't the right way
to do it or the syntax is bad.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,163
Default Need macro to open a variable filename

Workbooks.Open FileName:=Range("K6").Value

"Steve@ABS" wrote:

I have a variable filename in a cell. The cell, K6, contains "
concatenate(K4,H4)"
I recorded a macro that opens "filename" using
Workbooks.Open FileName:= "filename"
but the filename is hard coded as the name when the macro was recorded, not
a variable name. How do I get the macro to open the variable filename in K6?
I am not a VB programmer.

I tried Workbooks.Open FileName:= (K6) but either it isn't the right way
to do it or the syntax is bad.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Need macro to open a variable filename

Thanks, that works. Now I have a similar problem switching between open
worksheets:
Windows ("H33").Activate where H33 is the name of the worksheet we
opened in K6 minus the path.

"K Dales" wrote:

Workbooks.Open FileName:=Range("K6").Value

"Steve@ABS" wrote:

I have a variable filename in a cell. The cell, K6, contains "
concatenate(K4,H4)"
I recorded a macro that opens "filename" using
Workbooks.Open FileName:= "filename"
but the filename is hard coded as the name when the macro was recorded, not
a variable name. How do I get the macro to open the variable filename in K6?
I am not a VB programmer.

I tried Workbooks.Open FileName:= (K6) but either it isn't the right way
to do it or the syntax is bad.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,120
Default Need macro to open a variable filename

Same principle

Windows (Range("H33").Value).Activate

--
HTH

Bob Phillips

"Steve@ABS" wrote in message
...
Thanks, that works. Now I have a similar problem switching between open
worksheets:
Windows ("H33").Activate where H33 is the name of the worksheet we
opened in K6 minus the path.

"K Dales" wrote:

Workbooks.Open FileName:=Range("K6").Value

"Steve@ABS" wrote:

I have a variable filename in a cell. The cell, K6, contains "
concatenate(K4,H4)"
I recorded a macro that opens "filename" using
Workbooks.Open FileName:= "filename"
but the filename is hard coded as the name when the macro was

recorded, not
a variable name. How do I get the macro to open the variable filename

in K6?
I am not a VB programmer.

I tried Workbooks.Open FileName:= (K6) but either it isn't the

right way
to do it or the syntax is bad.





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,120
Default Need macro to open a variable filename

Workbooks.Open FileName:= Range("K6").Value

--
HTH

Bob Phillips

"Steve@ABS" wrote in message
...
I have a variable filename in a cell. The cell, K6, contains "
concatenate(K4,H4)"
I recorded a macro that opens "filename" using
Workbooks.Open FileName:= "filename"
but the filename is hard coded as the name when the macro was recorded,

not
a variable name. How do I get the macro to open the variable filename in

K6?
I am not a VB programmer.

I tried Workbooks.Open FileName:= (K6) but either it isn't the right

way
to do it or the syntax is bad.



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro to open most recent file with a particular filename string kwiklearner Excel Discussion (Misc queries) 1 August 23rd 06 01:24 AM
set filename to <filename-date on open bob engler Excel Worksheet Functions 2 July 13th 06 05:11 AM
Put Filename Variable in Macro David Excel Discussion (Misc queries) 4 December 27th 05 06:27 PM
Macro to open SaveAs... and change filename to cell value Andy Excel Programming 5 July 19th 04 12:23 PM
Can a MACRO prompt for the filename to open and/or save? Dave Peterson[_3_] Excel Programming 1 September 3rd 03 04:53 PM


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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"