exxist
Goto Top

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

Content-Key: 283491

Url: https://administrator.de/contentid/283491

Printed on: April 20, 2024 at 01:04 o'clock

Mitglied: 122990
122990 Sep 21, 2015 updated at 09:35:20 (UTC)
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
Member: ExxiSt
ExxiSt Sep 21, 2015 at 11:14:17 (UTC)
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
Mitglied: 122990
Solution 122990 Sep 21, 2015 updated at 13:45:49 (UTC)
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 & ")"