Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default controlling cell borders in excel using VB

I hve a VB application that is using the copyfromrecordset
function to transfer the an ADODB recordset to an excel
file starting in cell A8 filling the range ("A8":"Z37")
"Z37" varies depending on the query being executed. The
resulting range could be anywhere from ("A8":"D9") to
("A8":"BZ1200")
I would like to set the border to "all borders" just for
the specified range. Can anyone explain how this can be
acomplished?
Any help would be greatly appreciated
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 32
Default controlling cell borders in excel using VB

Eli,

Here is one thought. How about using "Conditional Formatting".

1) Select cell A8 on your worksheet.
2) Select "Format | Conditional Formatting..." from the menubar.
3) In the dropdown box select "Formula Is".
4) Type: =LEN(A8)0 in the edit box to the right
5) Click the Format... button.
6) Select the Border tab and click the "Outline" button and click OK.
7) Click OK in the original dialog box.
8) Copy cell A8 and Paste Special (Formats ONLY) to cells A8:BZ1200

If there is any number or text in any of the cells in the range A8:BZ1200,
they will show the outline format. If the cell results in an error (i.e.
#DIV0!, #VALUE, etc.) it won't be given the formatting. If you want error
cells to also be formatted then add a second conditional formatting by
clicking the "Add" button and using a formula of: =ISERR(A8)

Troy


"eli silverman" wrote in message
...
I hve a VB application that is using the copyfromrecordset
function to transfer the an ADODB recordset to an excel
file starting in cell A8 filling the range ("A8":"Z37")
"Z37" varies depending on the query being executed. The
resulting range could be anywhere from ("A8":"D9") to
("A8":"BZ1200")
I would like to set the border to "all borders" just for
the specified range. Can anyone explain how this can be
acomplished?
Any help would be greatly appreciated



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default controlling cell borders in excel using VB

Sub AddBorders()
With Range("A8").CurrentRegion
.Borders(xlDiagonalDown).LineStyle = xlNone
.Borders(xlDiagonalUp).LineStyle = xlNone
With .Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With .Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With .Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With .Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With .Borders(xlInsideVertical)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With .Borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
End With
End Sub

--
Regards,
Tom Ogilvy


eli silverman wrote in message
...
I hve a VB application that is using the copyfromrecordset
function to transfer the an ADODB recordset to an excel
file starting in cell A8 filling the range ("A8":"Z37")
"Z37" varies depending on the query being executed. The
resulting range could be anywhere from ("A8":"D9") to
("A8":"BZ1200")
I would like to set the border to "all borders" just for
the specified range. Can anyone explain how this can be
acomplished?
Any help would be greatly appreciated



Reply
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
missing cell borders in Excel Nak Excel Discussion (Misc queries) 8 April 22nd 23 06:11 AM
Controlling word wrap in a cell Victor Delta[_2_] Excel Discussion (Misc queries) 2 February 14th 10 10:58 PM
Controlling which cell you go to when Tab is entered carrera Excel Discussion (Misc queries) 1 August 22nd 07 04:53 PM
how do i set wrapping to see cell borders behind a pic in excel risrael Excel Discussion (Misc queries) 0 December 2nd 06 09:34 PM
Excel 2003 - Cell Borders oceanmist Excel Discussion (Misc queries) 1 October 23rd 06 07:13 PM


All times are GMT +1. The time now is 10:24 AM.

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

About Us

"It's about Microsoft Excel"