Option Explicit ' Sammelprotokoll Makro
Sub daten_uebernehmen()
Application.Calculation = xlManual
Application.EnableEvents = False / True
Dim Counter As Long
Dim h As Long
Dim i As Integer
Dim strFile As String
Dim strPath As String
Dim strDate As String
Dim loZeileZielmappe As Long
Dim inSpalte As Integer
Dim loZeileQuellmappe As Long
Dim ZielDatumZeile As Long
Dim ZielDateinameZeile As Long
Dim ZielDatumSpalte As Long
Dim loZaehler As Long
Dim myDefaultPath As Variant
Dim intCounter As Integer
myDefaultPath = ""
strPath = GetFolder(myDefaultPath, "Ordner auswählen...")
If strPath = "" Then Exit Sub
If Right(strPath, 1) <> "\" Then strPath = strPath & "\"
Application.ScreenUpdating = False
loZeileZielmappe = 6
loZaehler = 6
ZielDatumZeile = 6
ZielDateinameZeile = 7
ZielDatumSpalte = 1
Counter = 0
i = 6
With Application.FileSearch
.LookIn = strPath
.SearchSubFolders = True
.NewSearch
.Filename = "*.xls"
.FileType = msoFileTypeExcelWorkbooks
If .Execute(SortBy:=msoSortByFileName) > 0 Then '(SortBy:=msoSortByFileDate, _SortOrder:=msoSortOrderAscending)
For h = 1 To .FoundFiles.Count
SplitPath .FoundFiles(h), strPath, strFile
If strFile <> ThisWorkbook.Name Then
Range(Cells(loZaehler, 2), Cells(loZaehler + 24, 7)).Formula = _
"='" & strPath & "[" & strFile & "]" & "Tabelle1'!B8"
Cells(ZielDatumZeile, ZielDatumSpalte).Formula = "='" & strPath & "[" & strFile & "]" & "tabelle1" & "'!A33"
Cells(ZielDatumZeile, ZielDatumSpalte).Copy
Cells(ZielDatumZeile, ZielDatumSpalte).PasteSpecial Paste:=xlPasteValues
Cells(ZielDateinameZeile, ZielDatumSpalte) = strFile
End If
For intCounter = 1 To 25
Cells(i, 8).Formula = Application.WorksheetFunction.Average(Worksheets("Tabelle1").Range("B" & i & ":F" & i))
i = i + 1
Next
i = i + 2
loZaehler = loZaehler + 27
ZielDatumZeile = ZielDatumZeile + 27
ZielDateinameZeile = ZielDateinameZeile + 27
loZeileZielmappe = loZaehler
' strFile = Dir()
Counter = Counter + 125
Next
End If
End With
Range("B6:G" & loZeileZielmappe).Copy
Range("B6:G" & loZeileZielmappe).PasteSpecial Paste:=xlPasteValues
Application.CutCopyMode = False
Application.ScreenUpdating = True
Range("L7") = Counter
Range("K13") = Counter / 5
' Platzhalter
Range("H4") = Now()
Application.Calculation = xlAutomatic
End Sub
Private Function GetFolder(Optional ByVal varDefDir As Variant = "", Optional ByVal strTitle As String = "")
Dim objShell As Object, objFolder As Object
GetFolder = ""
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.BrowseForFolder(0&, strTitle, 0&, varDefDir)
If Not objFolder Is Nothing Then GetFolder = objFolder.Self.Path
Set objFolder = Nothing
Set objShell = Nothing
Range("h3") = Now()
End Function
Private Function SplitPath(ByVal strFullName As String, _
ByRef strPath As String, ByRef strName As String) As Boolean
Dim intPos As Integer
intPos = InStrRev(strFullName, "\")
If intPos > 0 Then
strPath = Left(strFullName, intPos)
strName = Mid(strFullName, intPos + 1)
Else
strPath = ""
strName = strFullName
End If
SplitPath = intPos > 0
End FunctionOption Explicit
Sub daten_uebernehmen()
Application.Calculation = xlManual
Application.EnableEvents = False / True
Dim Counter As Long
Dim Addition As Long
Dim avg As Long
Dim h As Long
Dim i As Integer
Dim j As Integer
Dim strFile As String
Dim strPath As String
Dim loZeileZielmappe As Long
Dim inSpalte As Integer
Dim loZeileQuellmappe As Long
Dim ZielDatumZeile As Long
Dim ZielDateinameZeile As Long
Dim Datum As String
Dim ZielDatumSpalte As Long
Dim loZaehler As Long
Dim myDefaultPath As Variant
Dim intCounter As Integer
myDefaultPath = ""
strPath = GetFolder(myDefaultPath, "Ordner auswählen...")
If strPath = "" Then Exit Sub
If Right(strPath, 1) <> "\" Then strPath = strPath & "\"
Application.ScreenUpdating = False
loZeileZielmappe = 6
loZaehler = 6
ZielDatumZeile = 5
ZielDateinameZeile = 6
ZielDatumSpalte = 1
Counter = 0
i = 6
With Application.FileSearch
.LookIn = strPath
.SearchSubFolders = True
.NewSearch
.Filename = "*.xls"
.FileType = msoFileTypeExcelWorkbooks
If .Execute > 0 Then
For h = 1 To .FoundFiles.Count
SplitPath .FoundFiles(h), strPath, strFile
' Debug.Print .FoundFiles(i), strPath, strFile
If strFile <> ThisWorkbook.Name Then
Range(Cells(loZaehler, 2), Cells(loZaehler + 24, 7)).Formula = _
"='" & strPath & "[" & strFile & "]" & "Tabelle1'!B8"
Cells(ZielDatumZeile, ZielDatumSpalte).Formula = "='" & strPath & "[" & strFile & "]" & "tabelle1" & "'!A33"
Cells(ZielDateinameZeile, ZielDatumSpalte) = strFile
End If
For intCounter = 1 To 25
Cells(i, 8) = (Cells(i, 2) + Cells(i, 3) + Cells(i, 4) + Cells(i, 5) + Cells(i, 6)) / 5
i = i + 1
Next
i = i + 2
loZaehler = loZaehler + 27
ZielDatumZeile = ZielDatumZeile + 27
ZielDateinameZeile = ZielDateinameZeile + 27
loZeileZielmappe = loZaehler
' strFile = Dir()
Counter = Counter + 125
Next
End If
End With
Range("B6:G" & loZeileZielmappe).Copy
Range("B6:G" & loZeileZielmappe).PasteSpecial Paste:=xlPasteValues
Application.CutCopyMode = False
Application.ScreenUpdating = True
Addition = Range("L8")
Range("L7") = Counter
Range("K13") = Counter / 5
Range("L8") = "=SUM(B6:F65536)"
Range("L9") = "=MIN(B6:F65536)"
Range("L10") = "=MAX(B6:F65536)"
Range("L11") = "=L8/L7"
Range("I14") = "=SUM(B6:B65536)"
Range("I15") = "=SUM(C6:C65536)"
Range("I16") = "=SUM(D6:D65536)"
Range("I17") = "=SUM(E6:E65536)"
Range("I18") = "=SUM(F6:F65536)"
Range("L14") = "=I14/K13"
Range("L15") = "=I15/K13"
Range("L16") = "=I16/K13"
Range("L17") = "=I17/K13"
Range("L18") = "=I18/K13"
Range("h4") = Now()
End Sub
Private Function GetFolder(Optional ByVal varDefDir As Variant = "", Optional ByVal strTitle As String = "")
Dim objShell As Object, objFolder As Object
GetFolder = ""
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.BrowseForFolder(0&, strTitle, 0&, varDefDir)
If Not objFolder Is Nothing Then GetFolder = objFolder.Self.Path
Range("h3") = Now()
Set objFolder = Nothing
Set objShell = Nothing
End Function
Private Function SplitPath(ByVal strFullName As String, _
ByRef strPath As String, ByRef strName As String) As Boolean
Dim intPos As Integer
intPos = InStrRev(strFullName, "\")
If intPos > 0 Then
strPath = Left(strFullName, intPos)
strName = Mid(strFullName, intPos + 1)
Else
strPath = ""
strName = strFullName
End If
SplitPath = intPos > 0
End Function
Dim varFuellArr(65531, 8) As Variant
varFuellArr(loZaehler , 2) = "='" & strPath & "[" & strFile & "]" & "Tabelle1'!B8"
varFuellArr(ZielDateinameZeile, ZielDatumSpalte) = strFile
varFuellArr(ZielDatumZeile, ZielDatumSpalte) = "='" & strPath & "[" & strFile & "]" & "tabelle1" & "'!A33"Call EventsOffCall EventsOnPublic Sub EventsOff()
With Application
.ScreenUpdating = False
.EnableEvents = False
.Calculation = xlCalculationManual
End With
End SubPublic Sub EventsOn()
With Application
.ScreenUpdating = True
.EnableEvents = True
.Calculation = xlCalculationAutomatic
End With
End SubOption Explicit
Option Base 1
Sub DateienNamenLesen()
Dim DateiPath As String
Dim DateiEndung As String
Dim DateiName As String
Dim DateiNamen() As String
Dim Zaehler1 As Long
DateiPath = "C:\Excel\"
DateiEndung = "*.xls"
Zaehler1 = 1
ReDim Preserve DateiNamen(Zaehler1)
DateiName = Dir(DateiPath & DateiEndung)
DateiNamen(Zaehler1) = DateiPath & DateiName
DateiName = Dir
Do While DateiName <> ""
Zaehler1 = Zaehler1 + 1
ReDim Preserve DateiNamen(Zaehler1)
DateiNamen(Zaehler1) = DateiPath & DateiName
DateiName = Dir
Loop
End SubOption Explicit
Option Base 1
Private Sub Workbook_Open()
Dim DateiPath As String
Dim DateiEndung As String
Dim DateiName As String
DateiPath = "C:\Excel\"
DateiEndung = "*.xls"
Zaehler1 = 1
ReDim Preserve DateiNamen(Zaehler1)
DateiName = Dir(DateiPath & DateiEndung)
DateiNamen(Zaehler1) = DateiPath & DateiName
DateiName = Dir
Do While DateiName <> ""
Zaehler1 = Zaehler1 + 1
ReDim Preserve DateiNamen(Zaehler1)
DateiNamen(Zaehler1) = DateiPath & DateiName
DateiName = Dir
Loop
End SubGlobal DateiNamen() As String
Global Zaehler1 As Long
Range("A6:G" & loZeileZielmappe).Copy
Range("A6:G" & loZeileZielmappe).PasteSpecial Paste:=xlPasteValues
Range(Cells(loZaehler, 2), Cells(loZaehler + 24, 7)).Formula = _
"='" & strPath & "[" & strFile & "]" & "Tabelle1'!B8"
Makros - zweiten Drucker als Symbol in die Symbolleiste einfügen
Mikoop 24.11.2006 - 4092 Hits - 1 Antwort
Verbessern eines Makros
Sp|n.aT 20.06.2007 - 72 Hits - 10 Antworten
makros in excel
struux 20.06.2007 - 79 Hits - 1 Antwort
zwei Makros mit einer Schaltfläche ausführen.
bokap1975 15.08.2007 - 16 Hits - 8 Antworten