eric2001
Terugkerende gebruiker
- Lid geworden
- 23 mrt 2001
- Berichten
- 1.600
Anderhalf jaar geleden had ik een vergelijkbaar probleem. Dat was toen opgelost, maar dezelfde macro werkt nu niet meer.
Ik wil om een selectie een kader maken en tussen de kolommen vertikale lijnen.
Dit werkt goed met de macro "kader en lijnen" hieronder.
Verder wil ik de rijen om en om een kleur geven. Dit werkt goed met de macro "balken" hieronder.
Maar als ik balken uitvoer en daarna kader en lijnen, verdwijnen de balken weer en andersom ook.
Ik zat eerst in de richting van Selection.FormatConditions.Delete te denken, maar als ik dat weghaalde werd het resultaat nog onvoorspelbaarder. (Wat doet dit precies trouwens?)
Wie weet een oplossing?
Sub kader()
'
'Macro: kader en lijnen
'
' Sneltoets: CTRL+k
'
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
Selection.FormatConditions.Delete
Selection.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=REST(KOLOM(A1);2)=0"
With Selection.FormatConditions(1).Borders(xlLeft)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.FormatConditions(1).Borders(xlRight)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
End Sub
Sub balken()
'
' Macro: balken
'
' Sneltoets: CTRL+c
'
Selection.FormatConditions.Delete
Selection.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=REST(RIJ(A1);2)=1"
Selection.FormatConditions(1).Interior.ColorIndex = 37
End Sub
Ik wil om een selectie een kader maken en tussen de kolommen vertikale lijnen.
Dit werkt goed met de macro "kader en lijnen" hieronder.
Verder wil ik de rijen om en om een kleur geven. Dit werkt goed met de macro "balken" hieronder.
Maar als ik balken uitvoer en daarna kader en lijnen, verdwijnen de balken weer en andersom ook.
Ik zat eerst in de richting van Selection.FormatConditions.Delete te denken, maar als ik dat weghaalde werd het resultaat nog onvoorspelbaarder. (Wat doet dit precies trouwens?)
Wie weet een oplossing?
Sub kader()
'
'Macro: kader en lijnen
'
' Sneltoets: CTRL+k
'
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
Selection.FormatConditions.Delete
Selection.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=REST(KOLOM(A1);2)=0"
With Selection.FormatConditions(1).Borders(xlLeft)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.FormatConditions(1).Borders(xlRight)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
End Sub
Sub balken()
'
' Macro: balken
'
' Sneltoets: CTRL+c
'
Selection.FormatConditions.Delete
Selection.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=REST(RIJ(A1);2)=1"
Selection.FormatConditions(1).Interior.ColorIndex = 37
End Sub