Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Formatting an excel cell - Borders

Posted on 2006-07-05
8
Medium Priority
?
239 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
8 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 2000 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …

636 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