#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Variables

Hi,

Two quick questions:

1. How do you include variables incode? I want a macro to open a file
dependent on the filename/ path which the user inputs to a form cell
H20. My attempt is

Workbooks.OpenText FileName:="L:\bacs\" & ActiveSheet.Range("H20") &
"", Origin:=xlWindows, _
StartRow:=1, DataType:=xlFixedWidth, OtherChar:=":",
FieldInfo:=Array( _
Array(0, 1), Array(4, 1))

2. How do you create a "flexible" macro that grows with the data?
Essentially I want to create a range A1:last but I don't know the code
for this.

Thanks for your help. Sorry my questions are so embarrassingly simple.

Richard



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Variables

Workbooks.OpenText FileName:="L:\bacs\" & ActiveSheet.Range("H20"), _
Origin:=xlWindows, _
StartRow:=1, DataType:=xlFixedWidth, OtherChar:=":",
FieldInfo:=Array( _
Array(0, 1), Array(4, 1))

Should work if H20 contains something like filename.txt

Dim rng as Range
set rng = Range("A1").CurrentRegion

--
Regards,
Tom Ogilvy


"richie" wrote in message
...
Hi,

Two quick questions:

1. How do you include variables incode? I want a macro to open a file
dependent on the filename/ path which the user inputs to a form cell
H20. My attempt is

Workbooks.OpenText FileName:="L:\bacs\" & ActiveSheet.Range("H20") &
"", Origin:=xlWindows, _
StartRow:=1, DataType:=xlFixedWidth, OtherChar:=":",
FieldInfo:=Array( _
Array(0, 1), Array(4, 1))

2. How do you create a "flexible" macro that grows with the data?
Essentially I want to create a range A1:last but I don't know the code
for this.

Thanks for your help. Sorry my questions are so embarrassingly simple.

Richard



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/



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
Not at all clear on use of variables and/or object variables JMay-Rke Excel Discussion (Misc queries) 11 July 4th 08 06:36 PM
How do I add variables Jez Excel Discussion (Misc queries) 1 January 15th 07 08:33 AM
More than 1 Variables [email protected] Excel Discussion (Misc queries) 1 November 29th 06 02:09 AM
Using variables . . . Wayne Knazek Excel Discussion (Misc queries) 2 July 6th 06 05:01 PM
Using variables in a name Vispy Excel Discussion (Misc queries) 4 February 22nd 06 01:17 AM


All times are GMT +1. The time now is 01:19 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"