Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 108
Default Trying to get better with Arrays...

The named range €˜FileList houses file names in a current directory Im
trying to loop through that list but am not sure how to get this set up
correctly€¦ I get a blank MsgBox and in turn the first file does not open. I
want to learn how to stay out of the spreadsheet for this issue using arrays
but am a bit stuck at the moment€¦

Appreciatively,
Arturo


Sub LoopFiles()

Set myRange = Range("A1").CurrentRegion
ActiveWorkbook.Names.Add Name:="FileList", RefersToR1C1:=myRange
Files2Alter = Array(myRange)
While X <= UBound(Files2Alter)
MsgBox Files2Alter(X)
Workbooks.Open FileName:=Files2Alter(X), UpdateLinks:=0
€˜Do X, Y & Z
€˜Close file and save changes
Wend
End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Trying to get better with Arrays...

Sub LoopFiles()

Set myRange = Range("A1").CurrentRegion.Columns(1)
ActiveWorkbook.Names.Add Name:="FileList", RefersToR1C1:=myRange
Files2Alter = myRange.Value
While X = lbound(Files2Alter,1) to UBound(Files2Alter,1)
MsgBox Files2Alter(X,1)
Workbooks.Open FileName:=Files2Alter(X,1), UpdateLinks:=0
€˜Do X, Y & Z
€˜Close file and save changes
Wend
End Sub

picking up a range, even a single column or single row range returns a two
dimensional array.

--
Regards,
Tom Ogilvy


"Arturo" wrote:

The named range €˜FileList houses file names in a current directory Im
trying to loop through that list but am not sure how to get this set up
correctly€¦ I get a blank MsgBox and in turn the first file does not open. I
want to learn how to stay out of the spreadsheet for this issue using arrays
but am a bit stuck at the moment€¦

Appreciatively,
Arturo


Sub LoopFiles()

Set myRange = Range("A1").CurrentRegion
ActiveWorkbook.Names.Add Name:="FileList", RefersToR1C1:=myRange
Files2Alter = Array(myRange)
While X <= UBound(Files2Alter)
MsgBox Files2Alter(X)
Workbooks.Open FileName:=Files2Alter(X), UpdateLinks:=0
€˜Do X, Y & Z
€˜Close file and save changes
Wend
End Sub

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 108
Default Trying to get better with Arrays...

Sub LoopFiles2()
Dim myRange As Range
Dim rO As Integer
Dim Files2Alter As Variant
Dim X As Variant

Set myRange = Range("A1").CurrentRegion.Columns(1)
ActiveWorkbook.Names.Add Name:="FileList", RefersToR1C1:=myRange
Files2Alter = myRange.Value
For X = LBound(Files2Alter, 1) To UBound(Files2Alter, 1)
MsgBox Files2Alter(X, 1)
Workbooks.Open FileName:=Files2Alter(X, 1), UpdateLinks:=0
Next X
End Sub



"Tom Ogilvy" wrote:

Sub LoopFiles()

Set myRange = Range("A1").CurrentRegion.Columns(1)
ActiveWorkbook.Names.Add Name:="FileList", RefersToR1C1:=myRange
Files2Alter = myRange.Value
While X = lbound(Files2Alter,1) to UBound(Files2Alter,1)
MsgBox Files2Alter(X,1)
Workbooks.Open FileName:=Files2Alter(X,1), UpdateLinks:=0
€˜Do X, Y & Z
€˜Close file and save changes
Wend
End Sub

picking up a range, even a single column or single row range returns a two
dimensional array.

--
Regards,
Tom Ogilvy


"Arturo" wrote:

The named range €˜FileList houses file names in a current directory Im
trying to loop through that list but am not sure how to get this set up
correctly€¦ I get a blank MsgBox and in turn the first file does not open. I
want to learn how to stay out of the spreadsheet for this issue using arrays
but am a bit stuck at the moment€¦

Appreciatively,
Arturo


Sub LoopFiles()

Set myRange = Range("A1").CurrentRegion
ActiveWorkbook.Names.Add Name:="FileList", RefersToR1C1:=myRange
Files2Alter = Array(myRange)
While X <= UBound(Files2Alter)
MsgBox Files2Alter(X)
Workbooks.Open FileName:=Files2Alter(X), UpdateLinks:=0
€˜Do X, Y & Z
€˜Close file and save changes
Wend
End Sub

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
Working with ranges in arrays... or an introduction to arrays Glen Excel Programming 5 September 10th 06 08:32 AM
Arrays - declaration, adding values to arrays and calculation Maxi[_2_] Excel Programming 1 August 17th 06 04:13 PM
Arrays Tobro88 Excel Discussion (Misc queries) 3 November 18th 05 11:28 PM
Arrays Ken Rock Excel Programming 3 November 17th 05 11:42 AM
Arrays Kenny Excel Programming 5 August 26th 04 09:47 AM


All times are GMT +1. The time now is 10:57 AM.

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

About Us

"It's about Microsoft Excel"