LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default Border Macros

I compiled a macro using the macro recorder to put borders around a
selection of cells.
However, I'm getting the following error when I do two cells.

Run-Time Error '1004': Unable to set the LineStyle property of the
Border class.

I know why this happens as well but not sure what to do to fix it.

Here is the VBA code for it:

Sub borders()
'
' borders Macro
' Macro recorded 24/08/2004 by Steven North
'
' Keyboard Shortcut: Ctrl+Shift+B
'
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 = 48
End With
With Selection.borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.Weight = xlHairline
.ColorIndex = 15
End With
End Sub

Is it possible to do an If statement i.e.

IF ISERROR(With Selection.border(xlInsideVertical)) Then
NEXT WITH
ELSE
CONTINUE
END WITH ????

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Border PL Excel Discussion (Misc queries) 3 July 10th 09 05:20 AM
border on last cell of page effects border on beginning cell of ne GaryE Excel Discussion (Misc queries) 0 March 23rd 09 05:47 AM
border Sarah Excel Worksheet Functions 2 December 2nd 07 12:55 AM
Πως μπορώ να συγκρίνω αν 2 κυψέλες έχουν το ίδιο border Stavros Excel Discussion (Misc queries) 0 August 16th 06 01:55 PM
Changing the border of one cell s/n change the border of adjacent gjanssenmn Excel Discussion (Misc queries) 2 October 5th 05 08:35 PM


All times are GMT +1. The time now is 12:36 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright 2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"