27.03.2022, 16:46 
		
	
	
		Hallo und einen weiterhin schönen So.
Ich hab da mal ein kleines Problem
Ich möchte am Ende der Woche die Summe der Stunden je Woche für den Monat
das Prinzip meiner Denke w = w + .Cells(n, 6).Value          natürlich mit     Dim w As Double  'je Woche
        w = w + .Cells(n, 6).Value          natürlich mit     Dim w As Double  'je Woche 
 für alle die mir den Vorschlag mit einer Formel machen ( ja es ist EINFACHER ) ich will aber VBA mal verstehen
 für alle die mir den Vorschlag mit einer Formel machen ( ja es ist EINFACHER ) ich will aber VBA mal verstehen  
 
Danke an alle die mir dabei Helfen
Hier noch mein Beispiel
Option Explicit
  
Private Sub Berechnen(Blatt As String)
    
Dim c As Long
Dim n As Long
Dim s As String
    
Dim d As Variant
Dim k As Collection
    
    
Dim w As Double 'Woche G
    
d = ThisWorkbook.Worksheets("Legende").Range("C7:L18").Value
    
With ThisWorkbook.Worksheets(Blatt)
      
For n = 18 To 59
c = Suchen(d, .Cells(n, 1).Value)
        
If c > 0 Then
.Cells(n, 4).Value = d(c, 5) '
.Cells(n, 5).Value = d(c, 6) '
.Cells(n, 6).Value = d(c, 6) - d(c, 5) '
        
          
If .Cells(n, 6).Value < 0 Then
            
.Cells(n, 6).Value = .Cells(n, 6).Value + 1
End If
          
End If
' w = w + .Cells(n, 6).Value
      
Next
End With
    
End Sub
	
Ich hab da mal ein kleines Problem
Ich möchte am Ende der Woche die Summe der Stunden je Woche für den Monat
das Prinzip meiner Denke
 w = w + .Cells(n, 6).Value          natürlich mit     Dim w As Double  'je Woche
        w = w + .Cells(n, 6).Value          natürlich mit     Dim w As Double  'je Woche  für alle die mir den Vorschlag mit einer Formel machen ( ja es ist EINFACHER ) ich will aber VBA mal verstehen
 für alle die mir den Vorschlag mit einer Formel machen ( ja es ist EINFACHER ) ich will aber VBA mal verstehen  
 Danke an alle die mir dabei Helfen

Hier noch mein Beispiel
Option Explicit
Private Sub Berechnen(Blatt As String)
Dim c As Long
Dim n As Long
Dim s As String
Dim d As Variant
Dim k As Collection
Dim w As Double 'Woche G
d = ThisWorkbook.Worksheets("Legende").Range("C7:L18").Value
With ThisWorkbook.Worksheets(Blatt)
For n = 18 To 59
c = Suchen(d, .Cells(n, 1).Value)
If c > 0 Then
.Cells(n, 4).Value = d(c, 5) '
.Cells(n, 5).Value = d(c, 6) '
.Cells(n, 6).Value = d(c, 6) - d(c, 5) '
If .Cells(n, 6).Value < 0 Then
.Cells(n, 6).Value = .Cells(n, 6).Value + 1
End If
End If
' w = w + .Cells(n, 6).Value
Next
End With
End Sub

 
 

 

 
	 
	
 
  
  
 