Joost.van.Steeg
Gebruiker
- Lid geworden
- 9 okt 2006
- Berichten
- 138
Ik was van plan bij een selectie de borders te zetten. Ik gebruikte hierbij de volgende code:
(colNumber is in dit geval 33, maar varieert dus)
Dit geeft echter de foutmelding: Run time error 1004 "Application-defined or object-defined error"
De volgende code doet precies hetzelfde en werkt wel.
Heeft iemand enig idee waarom de bovenstaande code een foutmelding geeft ?
(colNumber is in dit geval 33, maar varieert dus)
Code:
ActiveSheet(.Range(Cells(28, colNumber), Cells(58, colNumber))).Select
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
With Selection.Borders(xlInsideVertical)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
De volgende code doet precies hetzelfde en werkt wel.
Heeft iemand enig idee waarom de bovenstaande code een foutmelding geeft ?
Code:
X = 57
Do
X = X + 1
ActiveSheet.Cells(X, colNumber).Select
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
Loop Until X = 58