Hallo,
diese Makro führt in Zelle „B2“ Großschrift aus. Ich möchte Zellen hinzufügen zBsp. B3, B4. Wie muß ich das Makro erweitern?
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
On Error GoTo hell
If Sh.Name „Tabelle1“ Then Exit Sub
If Target.Value = „“ Or Target.Address(0, 0) „B2“ Then Exit Sub
If Target.HasFormula Then Exit Sub
Application.EnableEvents = False
Target.Value = Application.Proper(Target.Value)
hell:
Application.EnableEvents = True
End Sub
diese Makro führt in Zelle „B2“ Großschrift aus. Ich möchte
Zellen hinzufügen zBsp. B3, B4. Wie muß ich das Makro
erweitern?
Hallo Heimat,
du kannst das auch so schreiben:
Set Target = Intersect(Target, Range(„B2:B4“))
bei zusammenhängenden Zellen. So wie es im Code geschrieben ist, klappt es auch mit auseinanderliegenden Zellen.
Private Sub Workbook\_SheetChange(ByVal Sh As Object, ByVal Target As Range)
Dim Zelle As Range
On Error GoTo hell
If Sh.Name "Tabelle1" Then Exit Sub
Set Target = Intersect(Target, Range("B2, B3, B4"))
If Target Is Nothing Then Exit Sub
Application.EnableEvents = False
For Each Zelle In Target
If Zelle.Value "" And Not Zelle.HasFormula Then
Zelle.Value = Application.Proper(Zelle.Value)
End If
Next Zelle
hell:
Application.EnableEvents = True
End Sub