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

x
?
Solved

Excel VBA Best way to get border information of  a cell

Posted on 2014-03-10
3
Medium Priority
?
296 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

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.
This article describes a serious pitfall that can happen when deleting shapes using VBA.
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

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