Anzeige
Archiv - Navigation
948to952
Aktuelles Verzeichnis
Verzeichnis Index
Übersicht Verzeichnisse
Vorheriger Thread
Rückwärts Blättern
Nächster Thread
Vorwärts blättern
Anzeige
HERBERS
Excel-Forum (Archiv)
20+ Jahre Excel-Kompetenz: Von Anwendern, für Anwender
948to952
948to952
Aktuelles Verzeichnis
Verzeichnis Index
Verzeichnis Index
Übersicht Verzeichnisse
Inhaltsverzeichnis

Formatierung in Abhängigkeit eine Zelle

Formatierung in Abhängigkeit eine Zelle
14.02.2008 11:14:14
Torsten
Hallo,
habe eine kleines VBA-Proble. Ich habe eine kleine Beispieldatei. Dort werden in 3 Spalten Nr. Beschreibung und Art von Reklamationen aufgelistet. Ich will nun, dass sich bei Eingabe in der Spalte Art das Format von Spalte A und B in Abhängigkeit der Eingabe ändert. Habe die so gelöst:

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Application.Intersect(Target, Range("c1:c10")) Is Nothing Then
With Target
If .Value = "rej" Then
For i = 1 To 2
Target.Offset(0, -i).Activate
With ActiveCell.Borders(xlDiagonalDown)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlDiagonalUp)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
Target.Select
End With
Next i
Else
For i = 1 To 2
Target.Offset(0, -i).Activate
With ActiveCell.Borders(xlDiagonalDown)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlNone
End With
With Selection.Borders(xlDiagonalUp)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlNone
Target.Select
End With
Next i
End If
End With
End If
End Sub


Habe nun das Problem, dass die Zeilen nicht immer einzeln eingegebn werden, sondern die Daten oft aus einer zweiten Tabelle kopiert und eingefügt werden. Dabei kommt es aber zur Fehlmeldung: Laufzeitfehler 13, Typen unverträglich.
Wie kann ich das Problem umgehen/beseitigen.
Vielen Dank für eure Hilfe.

3
Beiträge zum Forumthread
Beiträge zu diesem Forumthread

Betreff
Datum
Anwender
Anzeige
AW: Formatierung in Abhängigkeit eine Zelle
14.02.2008 11:35:06
Rudi
Hallo,

Private Sub Worksheet_Change(ByVal Target As Range)
Dim rngC As Range, i As Integer
If Not Application.Intersect(Target, Range("c1:c10")) Is Nothing Then
For Each rngC In Target
With rngC
If .Value = "rej" Then
For i = 1 To 2
With .Offset(0, -i).Borders(xlDiagonalDown)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With .Offset(0, -i).Borders(xlDiagonalUp)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
Next i
Else
For i = 1 To 2
With .Offset(0, -i).Borders(xlDiagonalDown)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlNone
End With
With .Offset(0, -i).Borders(xlDiagonalUp)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlNone
End With
Next i
End If
End With
Next
End If
End Sub


Gruß
Rudi
Eine Kuh macht Muh, viele Kühe machen Mühe

Anzeige
AW: Formatierung in Abhängigkeit eine Zelle
14.02.2008 12:03:00
Beverly
Hi Torsten,

Private Sub Worksheet_Change(ByVal Target As Range)
Dim raBereich As Range
Set raBereich = Intersect(Target, Range("C1:C10"))
If Not raBereich Is Nothing Then
If raBereich.FormulaArray = "rej" Then
With Range(Cells(raBereich.Cells.Cells(1).Row, 1), Cells(raBereich(raBereich.Rows. _
Count).Row, 2))
With .Borders(xlDiagonalDown)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With .Borders(xlDiagonalUp)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
End With
Else
With Range(Cells(raBereich.Cells.Cells(1).Row, 1), Cells(raBereich(raBereich.Rows. _
Count).Row, 2))
With .Borders(xlDiagonalDown)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlNone
End With
With .Borders(xlDiagonalUp)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlNone
End With
End With
End If
End If
End Sub




Anzeige
AW: Formatierung in Abhängigkeit eine Zelle
14.02.2008 13:35:00
Torsten
Hallo ihr beiden,
vielen Dank für die schnelle Antwort.
Hat beides funktioniert.
Super!!!
Mfg Torsten

Beliebteste Forumthreads (12 Monate)

Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Anzeige