Jump to content

Recommended Posts

Posted (edited)

Sorry if this is a repost, but having some trouble searching for the answer and pretty tired right now.

I'm just wondering how to make a border around a range of cells in Excel. I want the regular lines created by selecting "All Borders" option around F2:G3

I saw this code:

With $oExcel.ActiveSheet.range("F2:G3")
    .Select
    .Borders($xlEdgeBottom).LineStyle = $xlContinuous
    .Borders($xlEdgeBottom).Weight = $xlThick
    .Borders($xlEdgeBottom).ColorIndex = $xlAutomatic
EndWith

but I get errors of these variables not existing. It seems these no longer exist in the "#include <Excel.au3>"

Is there another include file I need?

I got this to work for highlighting cells, wondering if there is a option similar to this for all borders?

$oExcel.ActiveSheet.Range("F2:G3").Interior.ColorIndex = 6

Thanks

Edited by AnonymousX
Posted

My UDFs and Tutorials:

  Reveal hidden contents

 

Posted (edited)
  On 4/18/2018 at 3:07 AM, water said:
Expand  

Thanks Water.

 

Didn't figure out a way to turn it into a one liner of code, to get just outside border for range, but can now get it to work with writing something for every case (Top, Bot, Left, Right).

Also from what you sent was able to write something to get all borders without having to write a line for top, bot, left, right. Might be useful to someone in the future

;Equivalent to "All Borders" for range given
    $oExcel.ActiveSheet.range("F2:G3").Borders.LineStyle = 1

 

Edited by AnonymousX
Posted

:)

My UDFs and Tutorials:

  Reveal hidden contents

 

  • 2 years later...
Posted

Hi, I tried the code below and it creates border for all cells from F2 to G3. what if i need only a common border for the range between F2 to G3. thanks 

  $oExcel.ActiveSheet.range("F2:G3").Borders.LineStyle = 1
Posted

Which of the enumerations I posted above did you try?

My UDFs and Tutorials:

  Reveal hidden contents

 

Posted

Hi, i just copied the line below to my code and it gave border to all cells between F2 and G3 . i was looking to box along the outer border.

$oExcel.ActiveSheet.range("F2:G3").Borders.LineStyle = 1
Posted

Perfect, it worked exactly how i wanted. Do you have reference link where i can try various option in excel - like changing font size, color etc ? thanks a lot

Posted

My UDFs and Tutorials:

  Reveal hidden contents

 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...