Re: Spalten formatieren

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Grüezi bustue

bustue schrieb am 30.06.2005

> gibt es eine Möglichkeit folgenden Code auf
> mehrere unabhängige Spalten zu ändern:
>
> Private Sub Worksheet_Change(ByVal Target As Range)
> If Target.Column <> 5 Then Exit Sub
> Target.Value = UCase(Target.Value)
> End Sub

JA; dafür gibt es mehrere Varianten:

Private Sub Worksheet_Change(ByVal Target As Range)
Set Target = Intersect(Target, Range("A:A,E:E,G:G"))
If Not Target Is Nothing Then
Application.EnableEvents = False
Target.Value = UCase(Target.Value)
Application.EnableEvents = True
End If
End Sub


Private Sub Worksheet_Change(ByVal Target As Range)
Select Case Target.Column
Case 1, 5, 7
Application.EnableEvents = False
Target.Value = UCase(Target.Value)
Application.EnableEvents = True
End Select
End Sub


Vielleicht solltest Du noch berücksichtigen, dass auch mehr als eine Zelle
gleichzeitig geändert werden kann, oder diesen Fall zuerst noch abfangen.


Mit freundlichen Grüssen
Thomas Ramel

--
- MVP für Microsoft-Excel -
[Win XP Pro SP-2 / xl2000 SP-3]
Microsoft Excel - Die ExpertenTipps:
(http://tinyurl.com/9ov3l und http://tinyurl.com/cmned)
.



Relevant Pages

  • Re: Nach Eingabe in Zelle automatisch Speichern
    ... habe den Code mal etwsa modifiziert, ... Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As ...
    (microsoft.public.de.excel)
  • Re: Date of last update when sheet has changed
    ... Private Sub Worksheet_Change(ByVal Target As Range) ... like that because there is a regular offset of 3 colums in the colum areas ... Dim r1 As Range, r2 As Range, r41 As Range ...
    (microsoft.public.excel.programming)
  • Re: Date of last update when sheet has changed
    ... Private Sub Worksheet_Change(ByVal Target As Range) ... like that because there is a regular offset of 3 colums in the colum ... select View Code - this brings up a VBE window ...
    (microsoft.public.excel.programming)
  • Re: Date of last update when sheet has changed
    ... Private Sub Worksheet_Change(ByVal Target As Range) ... Because it is worksheet code, ... select View Code - this brings up a VBE window ...
    (microsoft.public.excel.programming)
  • Re: VBA- Verfahren hemmt Performance- gehts anders?
    ... > Private Sub Worksheet_Change(ByVal Target As Range) ... ob das für Deinen Suchtext einen Unterschied macht. ... > Ich könnte k in einer Zelle vermerken. ...
    (microsoft.public.de.excel)