Ladebalken mit VBA
04.03.2019 11:56:35
Alexander
Wie bekomme ich meinen Code mit dem der den Ladebalken generiert zusaammen ?
Ladebalken Code:
Option Explicit
Public SW As Long
Public iMonat, iJahr As Long
Public anzTage, anzDaten As Long
Dim Schritt, Schritt1, Schritt2 As Double
Dim Länge, Länge1, Länge2 As Double
Dim i, z As Long
Dim j As Integer
Dim Spalte As Integer
Dim Farbe As Integer
Dim Tag As Integer
Sub Progressbar1()
SW = 3005 'Schrittweite festlegen
Länge = 0
Schritt = PB1.Label1.Width / SW 'Schrittbreite pro Aktualisierung
For i = 5 To SW
Cells(i, 1) = "Zeile " & i
Cells(i, 1).Interior.ColorIndex = 6
Länge = Länge + Schritt
PB1.Label2.Width = Länge
PB1.Label3.Caption = Format(i / SW, "0 %")
DoEvents
Next
Application.Wait (Now + TimeValue("0:00:2"))
Unload PB1
End Sub
Sub Progressbar2()
SW = 505
Länge1 = 0
Länge2 = 0
Schritt1 = PB2.Label1.Width / 10
Schritt2 = PB2.Label3.Width / SW
Farbe = 1
For j = 3 To 12
For i = 5 To SW
Cells(i, j).Interior.ColorIndex = Farbe
Farbe = Farbe + 1
If Farbe > 15 Then Farbe = 1
Länge2 = Länge2 + Schritt2
PB2.Label5.Width = Länge2
PB2.Label6.Caption = Format(i / SW, "0 %")
DoEvents
Next i
Länge2 = 0
Länge1 = Länge1 + Schritt1
PB2.Label2.Width = Länge1
PB2.Label3.Caption = Format((j - 2) / 10, "0 %")
DoEvents
Next j
Application.Wait (Now + TimeValue("0:00:2"))
Unload PB2
End Sub
Sub Progressbar3()
SW = 505
Länge1 = 0
Länge2 = 0
Schritt1 = PB3.Label1.Width / SW / 10
Schritt2 = PB3.Label3.Width / SW
Farbe = 1
For j = 3 To 12
For i = 5 To SW
Cells(i, j).Interior.ColorIndex = Farbe
Farbe = Farbe + 1
If Farbe > 15 Then Farbe = 1
Länge1 = Länge1 + Schritt1
PB3.Label2.Width = Länge1
PB3.Label3.Caption = Format(i / SW / 10 + (j - 3) / 10, "0 %")
Länge2 = Länge2 + Schritt2
PB3.Label5.Width = Länge2
PB3.Label6.Caption = Format(i / SW, "0 %")
DoEvents
Next i
Länge2 = 0
Next j
Application.Wait (Now + TimeValue("0:00:2"))
Unload PB3
End Sub
Sub Progressbar4()
SW = 100
Länge1 = 0
Länge2 = 0
Schritt1 = PB4.Label1.Width / anzTage
Schritt2 = PB4.Label3.Width / SW
Farbe = 1
Tag = 1
For j = 3 To anzTage + 2
Cells(5, j) = Tag
Tag = Tag + 1
For i = 6 To SW + 6
Cells(i, j).Interior.ColorIndex = Farbe
Farbe = Farbe + 1
If Farbe > 15 Then Farbe = 1
Länge2 = Länge2 + Schritt2
PB4.Label5.Width = Länge2
PB4.Label6.Caption = Format((i - 6) / SW, "0 %")
DoEvents
Next i
Länge2 = 0
Länge1 = Länge1 + Schritt1
PB4.Label2.Width = Länge1
PB4.Label3.Caption = Format((j - 2) / anzTage, "0 %")
PB4.Label7 = "abgearbeitete Tage: " & Tag & " von " & anzTage
DoEvents
Next j
Application.Wait (Now + TimeValue("0:00:2"))
Unload PB4
End Sub Mein Code der éinen Datenabgleich veranlasst:
Public Sub SearchEmploymentDate()
With Application
.ScreenUpdating = False
.Calculation = xlCalculationManual
.EnableEvents = False
End With
Dim lngRow As Long
Dim strFirstAddress As String, strMachine As String, strEmployee As String
Dim dtmMaxDate As Date
Dim objCell As Range
With ThisWorkbook.Worksheets("AuswertungDatum")
For lngRow = 1 To .Cells(.Rows.Count, 4).End(xlUp).Row
If Not IsEmpty(.Cells(lngRow, 4).Value) And .Cells(lngRow, 2).MergeCells Then
strEmployee = .Cells(lngRow, 4).Value
strMachine = .Cells(lngRow, 2).MergeArea.Cells(1)
dtmMaxDate = 0
With ThisWorkbook.Worksheets("ErfassungEinstätze")
Set objCell = .Columns(6).Find(What:=strEmployee, LookIn:=xlValues, _
LookAt:=xlWhole, MatchCase:=True)
If Not objCell Is Nothing Then
strFirstAddress = objCell.Address
Do
If strMachine = objCell.Offset(0, -2).Value Then
If IsDate(objCell.Offset(0, -3).Value) Then
dtmMaxDate = Application.max(dtmMaxDate, CDate(objCell. _
Offset(0, -3).Value))
Else
Call MsgBox(Prompt:="Fehler in Tabelle: ''ErfassungEinstä _
tze'' Zeile: " & _
CStr(objCell.Row) & vbLf & vbLf & "Bitte Eintrag in _
Spalte C prüfen.", _
Buttons:=vbCritical, Title:="Programmabbruch")
Set objCell = Nothing
Exit Sub
End If
End If
Set objCell = .Columns(6).FindNext(After:=objCell)
Loop Until objCell.Address = strFirstAddress
End If
Set objCell = Nothing
End With
If dtmMaxDate 0 Then
If IsDate(.Cells(lngRow, 6).Value) Then
If .Cells(lngRow, 6).Value