?
Solved

Excel VBA Best way to get border information of  a cell

Posted on 2014-03-10
3
Medium Priority
?
291 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:Murray Brown
[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
  • 2
3 Comments
 
LVL 39

Accepted Solution

by:
nutsch earned 2000 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:Murray Brown
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

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.

Question has a verified solution.

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

After seeing numerous questions for Dynamic Data Validation I notice that most have used Visual Basic to solve the problem. This suggestion is purely formula based and can be used in multiple rows.
If you need to forecast numbers -- typically for finance -- the Windows and Mac versions of Excel 2016 have a basket of tools to get the job done.
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa‚Ķ

777 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