Feedback by UserVoice

How can we improve Excel for Windows (Desktop Application)?

I would like to not have to select a range in VBA in order to to apply a Border. How to do it now: Range("J44:M44").Select With Selection.Bo

I would like to not have to select a range in VBA in order to to apply a Border.
How to do it now:
Range("J44:M44").Select
With Selection.Borders(xlEdgeTop)
.Weight = xlMedium
End With

Change to, no selection :
Range("J44:M44").Borders(xlEdgeTop).Weight = xlMedium
Thanks, David

2 votes
Sign in
(thinking…)
Password icon
Signed in as (Sign out)

We’ll send you updates on this idea

David shared this idea  ·   ·  Flag idea as inappropriate…  ·  Admin →
completed  ·  Dan Battagin [MS XL] responded  · 

Great news, that exact line of code you have there works just fine to apply borders, so you should be good to go.

Range(“J44:M44”).Borders(xlEdgeTop).Weight = xlMedium

Cheers,
Dan [MS]

2 comments

Sign in
(thinking…)
Password icon
Signed in as (Sign out)
Submitting...
  • David commented  ·   ·  Flag as inappropriate

    Hello Dan,

    Thank you very much. I tried this over again and indeed it worked! I have not idea what I might have done wrong on my other try. I do have a pretty old version of Excel on the computer and possibly I tried this with the older version.

    I would not have tried it again with out your response. Thanks again.

    David

  • David commented  ·   ·  Flag as inappropriate

    I would like to not have to select a range in VBA in order to to apply a Border.
    How to do it now:
    Range("J44:M44").Select
    With Selection.Borders(xlEdgeTop)
    .Weight = xlMedium
    End With

    Change to, no selection :
    Range("J44:M44").Borders(xlEdgeTop).Weight = xlMedium

Feedback and Knowledge Base