I used a procedure to consolidate data from other excel files in the same directory. It ran under Excel2003, but in 2007 it does not - the command selection.consolidate ends with Run-time error '1004'. I spent hours to find any hint, but found nothing. Do you have any experience?
Jirik
Code:
Sub Konsolidace()
Sheets("Výsledovka").Select
ActiveSheet.Unprotect
Cesta = Application.Workbooks(ActiveWorkbook.Name).Path
Obd = Range("a1")
Range("e13").Select
Selection.Consolidate Sources:=Array( _
Cesta + "\[F12_K00_Regiony.xlsm]Výsledovka!R13C5:R119C18", _
Cesta + "\[F12-105151.xlsx]Výsledovka!R13C5:R119C18", _
Cesta + "\[F12-120100.xlsx]Výsledovka!R13C5:R119C18", _
Cesta + "\[F12_K_HQ.xlsm]Výsledovka!R13C5:R119C18"), _
Function:=xlSum, TopRow:=False, LeftColumn:=False, CreateLinks:=False
Range("e164").Select
Selection.Consolidate Sources:=Array( _
Cesta + "\[F12_K00_Regiony.xlsm]Výsledovka!R164C5:R164C18", _
Cesta + "\[F12-105151.xlsx]Výsledovka!R164C5:R164C18", _
Cesta + "\[F12-120100.xlsx]Výsledovka!R164C5:R164C18", _
Cesta + "\[F12_K_HQ.xlsm]Výsledovka!R164C5:R164C18"), _
Function:=xlSum, TopRow:=False, LeftColumn:=False, CreateLinks:=False
ActiveSheet.Protect
Range("a1").Select
End Sub