exxist

Excel VBA Wenn Wert in Spalte A Werte und Formeln in weitere Spalten eintragen

Hallo zusammen,

Wenn in Spalte A "Ergebnis" steht, sollen wie unten beschrieben Formeln in die gleiche Zeile der danebenstehenden Spalten eingefügt werden.
Kann mir jemand verraten, was ich falsch mache?

Wäre für jeden Tipp dankbar!

Beste Grüße


Dim i As Long
   Application.ScreenUpdating = False
   For i = Cells(Rows.Count, 1).End(xlUp).Row To 1 Step -1
      If Cells(i, 1) = "Ergebnis" _  
      Then Cells(Rows.Count, 2) = "=R[-1]C[1]" _  
      And Cells(Rows.Count, 4) = "=zählenwenn(C:C;B101)" _  
      And Cells(Rows.Count, 6) = "=summewenn(C$:C$;$B101;F:F)" _  
      And Cells(Rows.Count, 7) = "=F101/H101-1" _  
      And Cells(Rows.Count, 8) = "=summewenn(C$:C$;$B101;H:H)" _  
      And Cells(Rows.Count, 10) = "=summewenn(C$:C$;$B101;N:N)" _  
      And Cells(Rows.Count, 11) = "=N101/P101-1" _  
      And Cells(Rows.Count, 12) = "=summewenn(C$:C$;$B101;P:P)" _  

   Next i
   Application.ScreenUpdating = True
Auf Facebook teilen
Auf X (Twitter) teilen
Auf Reddit teilen
Auf Linkedin teilen

Content-ID: 283491

Url: https://administrator.de/forum/excel-vba-wenn-wert-in-spalte-a-werte-und-formeln-in-weitere-spalten-eintragen-283491.html

Ausgedruckt am: 28.04.2025 um 19:04 Uhr

122990
122990 21.09.2015 aktualisiert um 11:35:20 Uhr
Goto Top
Moin,
da stimmt leider so einiges nicht...
   Dim i As Long
   Application.ScreenUpdating = False
   For i = Cells(Rows.Count, 1).End(xlUp).Row To 1 Step -1
      If Cells(i, 1).Value = "Ergebnis" then   
         Cells(i, 2).FormulaLocal = "=R[-1]C[1]"  
         Cells(i, 4).FormulaLocal = "=zählenwenn(C:C;B101)"  
         Cells(i, 6).FormulaLocal = "=summewenn($C:$C;$B101;F:F)"  
         Cells(i, 7).FormulaLocal = "=F101/H101-1"  
         Cells(i, 8).FormulaLocal = "=summewenn($C:$C;$B101;H:H)"  
         Cells(i, 10).FormulaLocal = "=summewenn($C:$C;$B101;N:N)"  
         Cells(i, 11).FormulaLocal = "=N101/P101-1"  
         Cells(i, 12).FormulaLocal = "=summewenn($C:$C;$B101;P:P)"  
      End if
   Next i
   Application.ScreenUpdating = True

Gruß grexit
ExxiSt
ExxiSt 21.09.2015 um 13:14:17 Uhr
Goto Top
Super, vielen Dank! Allerdings habe ich nun noch das Problem, dass die Formeln absolut sind und relativ sein sollten. Aktuell sind die Formeln darauf ausgelegt, dass "Ergebnis" in Zeile 101 gefunden wird. Wie kann ich das relativ machen? Viele Grüße
122990
Lösung 122990 21.09.2015 aktualisiert um 15:45:49 Uhr
Goto Top
Wie kann ich das relativ machen?
Indem du die Formeln zusammenbaust, und die aktuelle Zeile mit einbaust.
Beispiel:
Cells(i, 4).FormulaLocal = "=zählenwenn(C:C;B" & i & ")"