View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Don Guillett Don Guillett is offline
external usenet poster
 
Posts: 10,124
Default Simplify Code for Borders

Sub BorderInThin()

' With Selection.Borders = Array(xlInsideVertical, xlInsideHorizontal)
' .LineStyle = xlSolid
' .LineStyle = xlContinuous
' .Weight = xlThin
' .ColorIndex = xlAutomatic
' End With

'New code
myBorders = Array(, xlInsideVertical, xlInsideHorizontal)
For i = 1 To UBound(myBorders)
With Selection.Borders(myBorders(i))
.LineStyle = xlContinuous
.Weight = xlThin 'Medium
End With
Next
End Sub
'you may like this
Sub DoBorders() 'does inside and outside
With Selection
..Borders.LineStyle = xlContinuous
..BorderAround Weight:=xlMedium
End With
End Sub


--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"BEEJAY" wrote in message
...
Trying to work thru all my existing codes to "chop" them into smaller
pieces,
clean them up, re-arrange how they work together, etc.

I have seen samples of code for borders that greatly improve the
"recorded"
macros. My attempt, as follows, fails, as I really don't know what I am
doing.

My Original code will provide instruction as to what range the borders are
reqiured on. Then Call BorderInThin

Sub BorderInThin

With Selection.Borders = Array(xlInsideVertical, xlInsideHorizontal)
.LineStyle = xlSolid
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With

QUESTIONS:
1: What changes required to make the above work.
2: Where can one find detailed definitions of code expressions.
For example, using the "recorded" macro, I can comment out lineStyle =
xlSolid, AND LineStyle = xlContinuous and ColorIndex = xlAutomatic with no
APPARENT change in how the code works. I have to assume I'm missing
something
here, as well. I expect some definitions would be a good start.
3: I want to take a course on VBA that starts right back in
"kindergarten".
However, everyone seems to have switched the courses to MS Office 2007.
My company is still working with 2003 (and OO).
Is 2007 still using the same language?
If yes, I presume a current course would still be of benefit to learn
the basics I
am missing?
I hope someone can guide me on these issues.