Removing cell borders on any cell

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm familiar with writing code for Word 2003, and this is my first venture
into writing VBA code for Excel (2003). How can I edit the code (which
follows) to automatically remove the bottom border from *any* row rather than
removing it from a specific range? Following is the macro I recorded. I want
to replace the range with whatever code works in Excel to Select the same
number of cells. That way I could run the macro on any row. I guess what I
need to know is what is the Excel code for shift + right + right + right, so
that it selects a certain number of cells in the row? Here's the code:

Sub cmc1()
'
' cmc1 Macro
' Macro recorded 6/24/2005 by Claudia Carvalho
'
' Keyboard Shortcut: Ctrl+f
'
Range("A2779:I2779").Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
Selection.Borders(xlEdgeLeft).LineStyle = xlNone
Selection.Borders(xlEdgeTop).LineStyle = xlNone
Selection.Borders(xlEdgeBottom).LineStyle = xlNone
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlThick
.ColorIndex = xlAutomatic
End With
Range("A2779").Select
End Sub
 
Sub cmc1()
'
' cmc1 Macro
' Macro recorded 6/24/2005 by Claudia Carvalho
'
' Keyboard Shortcut: Ctrl+f
'
Selection.Resize(,3).Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
Selection.Borders(xlEdgeLeft).LineStyle = xlNone
Selection.Borders(xlEdgeTop).LineStyle = xlNone
Selection.Borders(xlEdgeBottom).LineStyle = xlNone
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlThick
.ColorIndex = xlAutomatic
End With
Range("A2779").Select
End Sub

change the 3 to select the number of columns you want
 
That worked great (after I changed "3" to "7" and removed the
Range("A2779").Select string from the bottom of the code. Thanks so much,
Tom.

Claudia
 
Back
Top