Solved

Excel VBA Best way to get border information of  a cell

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Improved? Move/Copy Add-in Replacement - How to avoid the annoying, “A formula or sheet you want to move or copy contains the name XXX, which already exists on the destination worksheet.” David Miller (dlmille)  It was one of those days… I wa…
Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

809 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