Clever-Excel-Forum

Normale Version: Ändern Makro Spalte 61 und 62
Du siehst gerade eine vereinfachte Darstellung unserer Inhalte. Normale Ansicht mit richtiger Formatierung.
Hallo Forum,

bei nachfolgendem Makro, welches prima funktioniert,  möchte ich, daß die Einfärbung der Spalte 61 und 62 nur in Spate 62 getätigt wird. Bitte um Hilfe.


Sub Equi_get_Gelb _Sp61()
Dim loLastRow As Long, iCnt1 As Long, iCnt2 As Long, boSecond As Boolean
loLastRow = Cells(Rows.Count, 61).End(xlUp).Row
For iCnt1 = 4 To loLastRow
  If IsNumeric(Cells(iCnt1, 61)) Then
    If Cells(iCnt1, 61) >= 1 And Cells(iCnt1, 61) <= 5000 Then
      With Range(Cells(iCnt1, 61), Cells(iCnt1, 62))
        If .Interior.Color <> 65535 Then
          .Interior.Color = 65535
          With .Borders(xlDiagonalUp)
            .LineStyle = xlContinuous
            .ColorIndex = xlAutomatic
            .Weight = xlThin
          End With
          Exit For
        End If
      End With
    End If
  End If
Next
If iCnt1 = loLastRow + 1 Then Exit Sub
For iCnt2 = loLastRow To iCnt1 Step -1
  If IsNumeric(Cells(iCnt1, 61)) Then
    If Cells(iCnt2, 61) >= 1 And Cells(iCnt2, 61) <= 5000 Then
      With Range(Cells(iCnt2, 61), Cells(iCnt2, 62))
        If .Interior.Color <> 65535 Then
          .Interior.Color = 65535
          With .Borders(xlDiagonalUp)
            .LineStyle = xlContinuous
            .ColorIndex = xlAutomatic
            .Weight = xlThin
          End With
          If boSecond Then Exit For
          boSecond = True
        End If
      End With
    End If
  End If
Next
End Sub


Im Voraus schon mal vielen Dank.

Grüsse Empo
Moin!
Schon mal darüber nachgedacht, dass man für so etwas eine simple bedingte Formatierung nimmt?
Vor allem, bevor man einen Code nimmt, den man nicht nachvollziehen kann?
Gut, Rahmen diagonal geht damit nicht, aber dies kann man ja auch anders regeln.

Gruß Ralf
Hallo Empo,

ersetze die beiden
With Range(Cells(iCnt1, 61), Cells(iCnt1, 62))
mit
With Cells(iCnt1, 62)
Gruß Uwe