• Privacywetgeving
    Het is bij Helpmij.nl niet toegestaan om persoonsgegevens in een voorbeeld te plaatsen. Alle voorbeelden die persoonsgegevens bevatten zullen zonder opgaaf van reden verwijderd worden. In de vraag zal specifiek vermeld moeten worden dat het om fictieve namen gaat.

Macro omvormen van 07 naar 03 compatibiliteit

Status
Niet open voor verdere reacties.

Avalondra

Gebruiker
Lid geworden
9 jan 2009
Berichten
150
Ik heb hier een macro gemaakt in 2007 en daar zit een voorwaardelijke opmaak in die niet
in 2003 wil werken kan iemand dan misschien helpen met het omvormen zodat het wel
in 2003 zal werken???

Ik denk zelf dat het aan de kleurcodes ligt maar het kan natuurlijk ook nog ergens anders aan liggen.

Code:
Range("D5").Select
    Selection.NumberFormat = "General"
    Range("D5").Activate
    Selection.FormatConditions.Add Type:=xlExpression, Formula1:="=$B5=WAAR"
    Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
    With Selection.FormatConditions(1).Interior
        .PatternColorIndex = xlAutomatic
        .ColorIndex = 44
        .TintAndShade = 0
    End With
    Selection.FormatConditions(1).StopIfTrue = True
    Range("D6:D34").Select
    Range("D5").Activate
    Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlGreaterEqual _
        , Formula1:="=8"
    Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
    With Selection.FormatConditions(1).Font
        .Bold = True
        .Italic = False
        .ColorIndex = 4
        .TintAndShade = 0
        .ThemeFont = xlThemeFontNone
    End With
    With Selection.FormatConditions(1).Interior
        .PatternColorIndex = xlAutomatic
        .ColorIndex = 16
        .TintAndShade = 0
    End With
    Selection.FormatConditions(1).StopIfTrue = True
    Range("D6:D34").Select
    Range("D5").Activate
    Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlLessEqual, _
        Formula1:="=4"
    Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
    With Selection.FormatConditions(1).Font
        .Bold = True
        .Italic = False
        .ColorIndex = 3
        .TintAndShade = 0
        .ThemeFont = xlThemeFontNone
    End With
    With Selection.FormatConditions(1).Interior
        .PatternColorIndex = xlAutomatic
        .ColorIndex = 16
        .TintAndShade = 0
    End With
    Selection.FormatConditions(1).StopIfTrue = True
    Range("D6:D34").Select
    Range("D5").Activate
    Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, _
        Formula1:="=""-"""
    Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
    With Selection.FormatConditions(1).Font
        .Bold = False
        .Italic = False
        .ColorIndex = xlAutomatic
        .TintAndShade = 0
        .ThemeFont = xlThemeFontNone
    End With
    With Selection.FormatConditions(1).Interior
        .PatternColorIndex = xlAutomatic
        .ColorIndex = 16
        .TintAndShade = 0
    End With
    Selection.FormatConditions(1).StopIfTrue = True
    Range("D5").Select
    Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, _
        Formula1:="=""-"""
    Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
    With Selection.FormatConditions(1).Interior
        .PatternColorIndex = xlAutomatic
        .Color = 8421504
        .TintAndShade = 0
    End With
    Selection.FormatConditions(1).StopIfTrue = True
    Range("D5").Select
    Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlLessEqual, _
        Formula1:="=4"
    Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
    With Selection.FormatConditions(1).Font
        .Bold = True
        .Italic = False
        .Color = -16776961
        .TintAndShade = 0
    End With
    With Selection.FormatConditions(1).Interior
        .PatternColorIndex = xlAutomatic
        .Color = 8421504
        .TintAndShade = 0
    End With
    Selection.FormatConditions(1).StopIfTrue = True
    Range("D5").Select
    Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlGreaterEqual _
        , Formula1:="=8"
    Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
    With Selection.FormatConditions(1).Font
        .Bold = True
        .Italic = False
        .Color = -16711936
        .TintAndShade = 0
    End With
    With Selection.FormatConditions(1).Interior
        .PatternColorIndex = xlAutomatic
        .Color = 8421504
        .TintAndShade = 0
    End With
    Selection.FormatConditions(1).StopIfTrue = True


Greetz AvA
 
Probeer eerst en vooral eens het massieve aantal Select, Selction en Activates uit je macro te verwijderen zodat je door het bos de bomen terug kan zien.
Een ander punt is dat in 2003 er slechts 3 CF mogelijk zijn, terwijl jij er voor zover ik kan zien 7 wil toevoegen

Mvg

Rudi
 
Ik heb al een manier gevonden. het zal waarschijnlijk nog korter ofzo kunnen maar dit werkt dus is het voldoende.


Code:
Range("C5").Select
    Selection.FormatConditions.Delete
    Selection.FormatConditions.Add Type:=xlExpression, Formula1:="=$B5=TRUE"
    Selection.FormatConditions(1).Font.ColorIndex = xlAutomatic
    Selection.FormatConditions(1).Interior.ColorIndex = 44
    Range("D5").Select
    Selection.FormatConditions.Delete
    Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, _
        Formula1:="=""-"""
    Selection.FormatConditions(1).Interior.ColorIndex = 16
    Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlGreaterEqual _
        , Formula1:="8"
    With Selection.FormatConditions(2).Font
        .Bold = True
        .Italic = False
        .ColorIndex = 4
    End With
    Selection.FormatConditions(2).Interior.ColorIndex = 16
    Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlLessEqual, _
        Formula1:="4"
    With Selection.FormatConditions(3).Font
        .Bold = True
        .Italic = False
        .ColorIndex = 3
    End With


Greetz AvA
 
Bedoel je zoiets ?
Code:
[C5:D5].FormatConditions.Delete
  With [C5].FormatConditions.Add (2, ,"=$B5=TRUE")
     .Interior.ColorIndex = 44
  End with 
  With [D5]
    with .FormatConditions.Add (1, 3,"=""-""")
      .Interior.ColorIndex = 16
    end with
    with .FormatConditions.Add (1, 7 ,"8")
      .Font.Bold = True
      .font.ColorIndex = 4
      .Interior.ColorIndex = 16
    end with
    With .FormatConditions.Add (1, 8,"4")
      .Font.Bold = True
      .Font.ColorIndex = 3
    End with
  End with
 
Laatst bewerkt:
Zou goed kunnen mercie.


Maar als je het niet erg vind houd ik nu de mijne want ik heb het programma al aan een vriend gegeven die het nodig had ( moest het voor hem maken) en nu heb ik een identiek excemplaar. (is makkelijker met helpen)


Greetz AvA
 
Als je mijn code begrijpt heb je je arsenaal aan methodes om voorwaardelijke opmaakcondities in VBA te maken aanzienlijk uitgebreid. Kun je ook anderen mee helpen (eventueel in dit forum)
 
Ok ik zal hem dan eens goed doorpluizen als ik wat tijd heb ( zal doordeweeks worden)

Greetz AvA
 
Status
Niet open voor verdere reacties.
Terug
Bovenaan Onderaan