Solved

Excel VBA Best way to get border information of  a cell

Posted on 2014-03-10
3
282 Views
Last Modified: 2014-03-10
Hi. I need to get information about the border formatting of a cell.
I am using the following code that gets the following results, which is
very different to the information in the macro recorder when
I initially formatted the cell (shown at the bottom)
L = 1
C = -4105
W = 2

Dim L, C, W As String
    L = Selection.Borders(xlEdgeTop).LineStyle
    C = Selection.Borders(xlEdgeTop).ColorIndex
    W = Selection.Borders(xlEdgeTop).Weight
       MsgBox W


    With Selection.Borders(xlEdgeTop)
        .LineStyle = xlContinuous
        .ColorIndex = 0
        .TintAndShade = 0
        .Weight = xlThin
    End With
0
Comment
Question by:murbro
  • 2
3 Comments
 
LVL 39

Accepted Solution

by:
nutsch earned 500 total points
ID: 39918750
Actually, xlContinuous is just an excel constant with a value of 1, xlThin has a value of 2, and the colorindex -4105 and 0 are the same color, so you are getting what you're putting in, even though it doesn't necessarily feel like it.

Thomas
0
 

Author Closing Comment

by:murbro
ID: 39918825
Great answer. Thanks Thomas
0
 
LVL 39

Expert Comment

by:nutsch
ID: 39918829
Glad to help. Thanks for the grade.

Thomas
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Approximate matching with VLOOKUP and MATCH seems to me to be a greatly under-used technique, and one which is vital for getting good performance out of large lookups. Until recently I would always have advised using an exact match for simplicity an…
Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

776 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