Solved

Excel VBA Best way to get border information of  a cell

Posted on 2014-03-10
3
276 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

A2 = A1 That kind of cell reference is relative.  If you copy it from A2 to B2, then B2 will get this: B2 = B1 That's all fine and good, but if you then insert a new row above row 2, you'll find: A3 = A1 B3 = B1 This is intentional. …
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.

706 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now