.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

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,286
Office Version
  1. 365
Platform
  1. Windows
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.
 

dinotom

Active Member
Joined
Aug 2, 2009
Messages
357
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
 

Jonmo1

MrExcel MVP
Joined
Oct 12, 2006
Messages
44,061
1. Remove the .Select - you don't select on the with line...
2. Correct syntax for borderaround is
.BorderAround Weight:= xlThin
 

dinotom

Active Member
Joined
Aug 2, 2009
Messages
357

ADVERTISEMENT

and the rngCDTemp.Select does select the proper range
 

dinotom

Active Member
Joined
Aug 2, 2009
Messages
357
Jonmo, Well that stopped the code from barfing but did NOT put the thin line around the range
 

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,286
Office Version
  1. 365
Platform
  1. Windows

ADVERTISEMENT

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
 

dinotom

Active Member
Joined
Aug 2, 2009
Messages
357
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
 

Jonmo1

MrExcel MVP
Joined
Oct 12, 2006
Messages
44,061
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:

Watch MrExcel Video

Forum statistics

Threads
1,130,048
Messages
5,639,769
Members
417,111
Latest member
buyukbang

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
Top