Solved

Formatting an excel cell - Borders

Posted on 2006-07-05
8
235 Views
Last Modified: 2010-04-23
Friends,

I need to put a border around each individual cell that I am including in a spreadsheet      The Range includes A1 through O22

So, I guess what I'm asking is what would the property setting (syntax) be?

Here is my code that accompanies it:

 With oSheet.Range("A1", "O" & NumberOfCarsInRace + 3)

            .VerticalAlignment = excel.XlVAlign.xlVAlignCenter
            .HorizontalAlignment = excel.XlHAlign.xlHAlignCenter

            '.Borders.Application.????????????????
0
Comment
Question by:indy500fan
  • 4
  • 4
8 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 17045526
With oSheet.Range("A1", "O" & NumberOfCarsInRace + 3)
         .VerticalAlignment = excel.XlVAlign.xlVAlignCenter
         .HorizontalAlignment = excel.XlHAlign.xlHAlignCenter

    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
  End With
0
 

Author Comment

by:indy500fan
ID: 17045580
I'm getting errors with the xl* items.  Is there something I need to declare that I'm not?
0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 17045621
I now see that you are in VB.net.

as I don't have VB.net handy, you will have to find the correct syntax, it will be similar to this:
xlContinuous  should be excel.XlLineStyle.xlLineStyleContinuous
etc
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Author Comment

by:indy500fan
ID: 17045715
??? Actually, I need help with that.  

As you said excel.XlLineStyle.xlLineStyleContinuous works, but I can't make the

With .Borders(xlEdgeBottom) work.
0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 17045753
xlEdgeBottom - > excel.XlBordersIndex.xlEdgeBottom
xlThin -> excel.XlBorderWeight.xlThin
xlAutomatic ->  Excel.XlColorIndex.xlColorIndexAutomatic
0
 

Author Comment

by:indy500fan
ID: 17045799
AngelIII,

Okay, that compiled, thanks for that; however, it puts a border around the whole set rather than each cell as I requested.  Any other suggestions?
0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 17045821
indeed, I forgot to copy 2 blocks:

    With .Borders(excel.XlBordersIndex.xlInsideVertical)
        .LineStyle = excel.XlLineStyle.xlContinuous
        .Weight = excel.XlBorderWeight.xlThin
        .ColorIndex = Excel.XlColorIndex.xlAutomatic
    End With
    With .Borders(excel.XlBordersIndex.xlInsideHorizontal)
        .LineStyle = excel.XlLineStyle.xlContinuous
        .Weight = excel.XlBorderWeight.xlThin
        .ColorIndex = Excel.XlColorIndex.xlAutomatic
    End With
0
 

Author Comment

by:indy500fan
ID: 17045907
angellIII,

Brilliant!  That works.  Thank you.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question