Sub PlaceFormula_2()
Dim ws As Worksheet
Dim rng As Range
Dim lr As Long, Col As Long
Dim Formula As String
Formula = "IF(A5<>SUM(E5:G5),""Caution!"",""ok"")"
Dim ColName As String
ColName = InputBox("choose column letter", "Set Column Letter")
If ColName = "" Then
MsgBox "You didn't select a column letter.", vbExclamation
Exit Sub
End If
Application.ScreenUpdating = False
For Each ws In Worksheets
Select Case ws.Name
Case "1_Index", "2_Auswertung", "3_Gesamtliste", "X_Sorting", "Y_ColumnHeader", "Z_Requirements"
Case Else
lr = ws.Cells(Rows.Count, "L").End(xlUp).Row
If lr > 4 Then
ws.Range(ws.Cells(5, Range(ColName & 1).Column), ws.Cells(lr, Range(ColName & 1).Column)).Formula = "=" & Formula
End If
End Select
lr = 0
Next ws
Application.ScreenUpdating = True
End Sub
Dim ColName As String
ColName = InputBox("choose column letter", "Set Column Letter")
If ColName = "" Then
MsgBox "You didn't select a column letter.", vbExclamation
Exit Sub
End If
If you use a ; (semicolon) in the formula instead of a , (comma), replace comma in line#5 with semicolon.
Open in new window