При использовании формул "" (Пусто) должно быть "" "", а "тест" должно быть "" тест ""
Изменить это:
Range("O2:O" & LastRow).Formula = "=WENN(Q2="";"";WENN(H2*7*Q2<L2;"Möglich";"Prüfen"))"
На это:
Sheet1.Range("O2:O" & LastRow).Formula = "=WENN(Q2="""";"""";WENN(H2*7*Q2<L2,""Möglich"",""Prüfen""))"
При необходимости также измените ";" на "," (зависит от версии Excel).
Полный код:
Option Explicit
Sub test()
Dim LastRow As Long
With ThisWorkbook.Worksheets("Sheet1") '<- Change sheet name if needed
LastRow = .Cells(.Rows.Count, "O").End(xlUp).Row '<- Change column lf needed. Have in mind that because Lastrow is in the with statement, Lastrow calculation related with the sheet in the with statemet
.Columns("A:M").Replace What:=",", Replacement:=".", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
.Range("N3:O24023,P2:P240023").ClearContents '<- ClearContents clear only Contents . if you want to clear everything use .Clear
.Range("N2:O2").AutoFill Destination:=Range("N2:O24023")
.Columns("A:O").EntireColumn.AutoFit
.Range("C:C,J:J,K:K,M:M").EntireColumn.Hidden = True
Rows("2:2").Select
ActiveWindow.FreezePanes = True
.Range("O2:O" & LastRow).Formula = "=IF(Q2="""",IF((H2*7*Q2)<L2,""Möglich"",""Prüfen""))"
End With
End Sub