.BorderAround

dinotom

Active Member
Joined
Aug 2, 2009
Messages
357
with rngCDTemp being set to a range (a valid range )

why does this bolded line produce an error (trying to put a thin line border around the whole range)

Code:
 With rngCDTemp.Select
        [B].BorderAround.Weight = xlThin[/B]
        ActiveWorkbook.Names.Add Name:=AcctName & "ChtDataTable", _
        RefersTo:=rngCDTemp
     End With
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
Thomas

Why do you have .Select?

Just remove that and I think the code should work.

Mind you I've got to ask what the code is actually meant to do and why you are using With.
 
Upvote 0
why does this bolded line produce an error (trying to put a thin line border around the whole range)

the code is to do whats in the parentheses

and I originally had rngCDTemp.BorderAround.Weight = xlThin which didnt work either
 
Upvote 0
1. Remove the .Select - you don't select on the with line...
2. Correct syntax for borderaround is
.BorderAround Weight:= xlThin
 
Upvote 0
Jonmo, Well that stopped the code from barfing but did NOT put the thin line around the range
 
Upvote 0
Thomas

You say the code is just meant to put a border round a range, why the Names part then?

Anyway there isn't actually a Weight property, this is how you refer to the Weight parameter when passing it to BorderAround.
Code:
    Set rngCDTemp = Range("A1:A10")
    
    rngCDTemp.BorderAround Weight:=xlThin
 
Upvote 0
I was using the With statement so I could do both, name the range and put the line around it. I am now trying to solve one problem at a time, namely putting the line around the range.

rngCDTemp.BorderAround Weight = xlThin this line, which I already had tried, doesn't put the line around either
 
Upvote 0
rngCDTemp.BorderAround Weight = xlThin this line, which I already had tried, doesn't put the line around either

ok, again....
The correct syntax is
rngCDTemp.BorderAround Weight:= xlThin

see the difference?
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,591
Messages
6,120,427
Members
448,961
Latest member
nzskater

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top