OK ... toro nu jeg er fattet lidt afligevel .... den laver en liste :o)
mit problem er nu at jeg ikke for nogle liste .... nogle der kan se hvor jeg har overset noget .... måske
____________________________________________________
Dim FolderName As String, wbName As String, r As Long, cValue As Variant
Dim wbList() As String, wbCount As Integer, i As Integer
FolderName = "F:\MSE\AMP\Tidsregistrering\Gemte tidsregistreringer\"
' create list of workbooks in foldername
wbCount = 0
wbName = Dir(FolderName & "\" & "*.xls")
While wbName <> ""
wbCount = wbCount + 1
ReDim Preserve wbList(1 To wbCount)
wbList(wbCount) = wbName
wbName = Dir
Wend
If wbCount = 0 Then Exit Sub
' get values from each workbook
r = 0
Workbooks.Add
For i = 1 To wbCount
r = r + 1
H4Value = GetInfoFromClosedFile(FolderName, wbList(i), "Ialt for ugen", "H4")
H5Value = GetInfoFromClosedFile(FolderName, wbList(i), "Ark17", "H5")
H6Value = GetInfoFromClosedFile(FolderName, wbList(i), "Ark17", "H6")
H7Value = GetInfoFromClosedFile(FolderName, wbList(i), "Ark17", "H7")
H8Value = GetInfoFromClosedFile(FolderName, wbList(i), "Ark17", "H8")
H9Value = GetInfoFromClosedFile(FolderName, wbList(i), "Ark17", "H9")
H10Value = GetInfoFromClosedFile(FolderName, wbList(i), "Ark17", "H10")
H11Value = GetInfoFromClosedFile(FolderName, wbList(i), "Ark17", "H11")
H12Value = GetInfoFromClosedFile(FolderName, wbList(i), "Ark17", "H12")
H13Value = GetInfoFromClosedFile(FolderName, wbList(i), "Ark17", "H13")
H14Value = GetInfoFromClosedFile(FolderName, wbList(i), "Ark17", "H14")
H15Value = GetInfoFromClosedFile(FolderName, wbList(i), "Ark17", "H15")
H16Value = GetInfoFromClosedFile(FolderName, wbList(i), "Ark17", "H16")
H17Value = GetInfoFromClosedFile(FolderName, wbList(i), "Ark17", "H17")
H18Value = GetInfoFromClosedFile(FolderName, wbList(i), "Ark17", "H18")
H19Value = GetInfoFromClosedFile(FolderName, wbList(i), "Ark17", "H19")
H20Value = GetInfoFromClosedFile(FolderName, wbList(i), "Ark17", "H20")
H21Value = GetInfoFromClosedFile(FolderName, wbList(i), "Ark17", "H21")
H22Value = GetInfoFromClosedFile(FolderName, wbList(i), "Ark17", "H22")
H23Value = GetInfoFromClosedFile(FolderName, wbList(i), "Ark17", "H23")
H24Value = GetInfoFromClosedFile(FolderName, wbList(i), "Ark17", "H24")
H25Value = GetInfoFromClosedFile(FolderName, wbList(i), "Ark17", "H25")
H26Value = GetInfoFromClosedFile(FolderName, wbList(i), "Ark17", "H26")
H27Value = GetInfoFromClosedFile(FolderName, wbList(i), "Ark17", "H27")
H28Value = GetInfoFromClosedFile(FolderName, wbList(i), "Ark17", "H28")
H29Value = GetInfoFromClosedFile(FolderName, wbList(i), "Ark17", "H29")
H30Value = GetInfoFromClosedFile(FolderName, wbList(i), "Ark17", "H30")
H31Value = GetInfoFromClosedFile(FolderName, wbList(i), "Ark17", "H31")
H32Value = GetInfoFromClosedFile(FolderName, wbList(i), "Ark17", "H32")
H33Value = GetInfoFromClosedFile(FolderName, wbList(i), "Ark17", "H33")
H34Value = GetInfoFromClosedFile(FolderName, wbList(i), "Ark17", "H34")
H35Value = GetInfoFromClosedFile(FolderName, wbList(i), "Ark17", "H35")
H36Value = GetInfoFromClosedFile(FolderName, wbList(i), "Ark17", "H36")
H37Value = GetInfoFromClosedFile(FolderName, wbList(i), "Ark17", "H37")
H38Value = GetInfoFromClosedFile(FolderName, wbList(i), "Ark17", "H38")
H39Value = GetInfoFromClosedFile(FolderName, wbList(i), "Ark17", "H39")
H40Value = GetInfoFromClosedFile(FolderName, wbList(i), "Ark17", "H40")
H41Value = GetInfoFromClosedFile(FolderName, wbList(i), "Ark17", "H41")
Cells(r, 1).Formula = wbList(i)
Cells(r, 2).Formula = H4Value
Cells(r, 3).Formula = H5Value
Cells(r, 4).Formula = H6Value
Cells(r, 5).Formula = H7Value
Cells(r, 6).Formula = H8Value
Cells(r, 7).Formula = H9Value
Cells(r, 8).Formula = H10Value
Cells(r, 9).Formula = H11Value
Cells(r, 10).Formula = H12Value
Cells(r, 11).Formula = H13Value
Cells(r, 12).Formula = H14Value
Cells(r, 13).Formula = H15Value
Cells(r, 14).Formula = H16Value
Cells(r, 15).Formula = H17Value
Cells(r, 16).Formula = H18Value
Cells(r, 17).Formula = H19Value
Cells(r, 18).Formula = H20Value
Cells(r, 19).Formula = H21Value
Cells(r, 20).Formula = H22Value
Cells(r, 21).Formula = H23Value
Cells(r, 22).Formula = H24Value
Cells(r, 23).Formula = H25Value
Cells(r, 24).Formula = H26Value
Cells(r, 25).Formula = H27Value
Cells(r, 26).Formula = H28Value
Cells(r, 27).Formula = H29Value
Cells(r, 28).Formula = H30Value
Cells(r, 29).Formula = H31Value
Cells(r, 30).Formula = H32Value
Cells(r, 31).Formula = H33Value
Cells(r, 32).Formula = H34Value
Cells(r, 33).Formula = H35Value
Cells(r, 34).Formula = H36Value
Cells(r, 35).Formula = H37Value
Cells(r, 36).Formula = H38Value
Cells(r, 37).Formula = H39Value
Cells(r, 38).Formula = H40Value
Cells(r, 39).Formula = H41Value
Next i
End Sub
_____________________________________________________________
Private Function GetInfoFromClosedFile(ByVal wbPath As String, wbName As String, wsName As String, cellRef As String) As Variant
Dim arg As String
GetInfoFromClosedFile = ""
If Right(wbPath, 1) <> "\" Then wbPath = wbPath & "\"
If Dir(wbPath & "\" & wbName) = "" Then Exit Function
arg = "'" & wbPath & "[" & wbName & "]" & wsName & "'!" & Range(cellRef).Address(True, True, xlR1C1)
On Error Resume Next
GetInfoFromClosedFile = ExecuteExcel4Macro(arg)
End Function
______________________________________________________________