Hi Sonaldo,
würde das wie folgt umsetzen:
Sub s_Summenformeln_schreiben()
Dim strSuchwort As String
Dim strCol As String
Dim strAdr As String
Dim lngCnt As Long
Dim intCol As Integer
Dim intZeile As Integer
Dim i As Integer
Dim intNaechsteSuchwortZeile As Integer
Dim varNaechstesSuchwort As Variant
'Spaltenzahl, hier L=12
intCol = 12
'Suchwort
strSuchwort = "Summe"
'Spaltenbuchstabe ermitteln
strAdr = ActiveSheet.Cells(1, intCol).Address
lngCnt = InStr(2, strAdr, "$") - 1
strCol = WorksheetFunction.Substitute(Left(strAdr, Len(strAdr) - (Len(strAdr) - lngCnt)), "$", "")
'Letzte Zeile herausfinden
intZeile = Cells(65536, intCol).End(xlUp).Row
'Erste Zelle aktivieren
Cells(1, intCol).Activate
For i = 1 To intZeile
If Cells(i, intCol) = strSuchwort Then
Columns(intCol).Find(What:=strSuchwort, After:=ActiveCell, LookIn:= _
xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:= _
xlNext, MatchCase:=False, SearchFormat:=False).Activate
intNaechsteSuchwortZeile = ActiveCell.Row
Cells(i, intCol).FormulaLocal = "=Summe(" & strCol & i + 1 & ":" & strCol & intNaechsteSuchwortZeile - 1 & ")"
End If
Next
End Sub
Bei Fragen einfach melden, hat bei mir soweit funktioniert.
LG Daniel
|