Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
missing cell borders in Excel | Excel Discussion (Misc queries) | |||
Controlling word wrap in a cell | Excel Discussion (Misc queries) | |||
Controlling which cell you go to when Tab is entered | Excel Discussion (Misc queries) | |||
how do i set wrapping to see cell borders behind a pic in excel | Excel Discussion (Misc queries) | |||
Excel 2003 - Cell Borders | Excel Discussion (Misc queries) |