LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #3   Report Post  
Posted to microsoft.public.excel.programming
Len Len is offline
external usenet poster
 
Posts: 162
Default Data range in Array worksheets

Hi Chip,

Thanks for your codes and it works fine independently
However, if I were to incorporate and modify your codes to run data
consolidation,
it fails and stops at mid line of codes with run time error "
Subscript out of range "
as indicated below

Sub Totals()

Application.DisplayAlerts = False
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual

Const MAXBOOK As Long = 4
Dim i%, SheetArg$()
Dim sPath1 As String
ReDim SheetArg(1 To MAXBOOK)

Dim sPath As String, sFile As String
Windows("Budget Consol.xls").Activate
ThisWorkbook.Worksheets("Sheet2").Cells.ClearConte nts
sPath = "M:\Help\LO\Budget\Budget Actual\Academic3\"
i = 0
sPath1 = "M:\Help\LO\Budget\Budget Actual\Academic3\*.xls"
sFile = Dir(sPath1, vbNormal)

Do While sFile < ""
i = i + 1
Dim WB As Workbook
ChDir "M:\Help\LO\Budget\Budget Actual\Academic3"
Set WB = Workbooks.Open(sFile)
WB.Worksheets("P+L").Select
Dim k As Long
Dim Lstrow As Long
Lstrow = Cells(Rows.Count, "A").End(xlUp).Row
If Lstrow 0 Then
For k = 5 To Lstrow
If Cells(k, 1).Value < "" Then
Cells(k, 1).Copy
Cells(k, 2).Select
ActiveSheet.Paste
Application.CutCopyMode = False

End If
Next
Else
MsgBox "It appears that the file is empty, check the file again"
Exit Sub
End If
WB.Close SaveChanges:=True
------------------- xxxxx Run Time Error
xxxxxxxxx---------------------------
SheetArg(i) = "'" & sPath & "[" & sFile & "]P+L'!R6C2:R47C15 "
sFile = Dir()
Loop

ThisWorkbook.Sheets("Sheet2").Range("A1").Consolid ate _
Sources:=Array(SheetArg), Function:=xlSum, TopRow:=True, _
LeftColumn:=True, CreateLinks:=True

Please help up as I still unable to rectify it after debug the error

Thanks & Regards
Len

 
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
Efficiently moving data between worksheets and VBA array variables Fred Excel Programming 1 October 11th 09 07:55 PM
Moving data from an array to a range when range consists of areas? kfguardian Excel Programming 3 June 8th 08 04:04 PM
Redimming an array dynamically assigned from range (how to redim first dimension of a 2-D array? /or/ reverse the original array order) Keith R[_2_] Excel Programming 3 November 13th 07 04:08 PM
Q: Best way to take data from VBA into graphs without writing data to worksheets? (Can a named range refer to an array in memory only?) KR Excel Programming 2 December 16th 04 11:12 PM
Read Range Data into Array Stratuser Excel Programming 1 April 26th 04 06:46 PM


All times are GMT +1. The time now is 05:19 PM.

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"