Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Cell bordering

Hi All,

I have a range (A22:A95) which has a left and right cell border.
The right cell border gets changed by other macros.
What im trying to do, is set the right border the same as left border for
each cell in the selection. Below is the code i currently have:

---------------------------------------------------------

Dim c As Range
For Each c In Selection
With c.Borders(xlEdgeLeft)
CellThickness = c.Borders.Weight
CellColorIndex = c.Borders.ColorIndex
End With
With c.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = CellThickness
.ColorIndex = CellColorIndex
End With
Next c

------------------------------------------
This code changes the right border but not to the same as the left. I.e. it
puts the line as dotted, and if the left side of the cell has a border, and
if the left side is blank, it puts in a think line on the right side of the
cell.

Can anyone please asist.

Cheers.
Al.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 863
Default Cell bordering

See if it works correctly this way:

Dim c As Range
For Each c In Selection
With c.Borders(xlEdgeLeft)
CellThickness = .Weight
CellColorIndex = .ColorIndex
End With
With c.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = CellThickness
.ColorIndex = CellColorIndex
End With
Next c

On Tue, 12 Oct 2004 17:03:03 -0700, "Albert Jameson"
wrote:

Hi All,

I have a range (A22:A95) which has a left and right cell border.
The right cell border gets changed by other macros.
What im trying to do, is set the right border the same as left border for
each cell in the selection. Below is the code i currently have:

---------------------------------------------------------

Dim c As Range
For Each c In Selection
With c.Borders(xlEdgeLeft)
CellThickness = c.Borders.Weight
CellColorIndex = c.Borders.ColorIndex
End With
With c.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = CellThickness
.ColorIndex = CellColorIndex
End With
Next c

------------------------------------------
This code changes the right border but not to the same as the left. I.e. it
puts the line as dotted, and if the left side of the cell has a border, and
if the left side is blank, it puts in a think line on the right side of the
cell.

Can anyone please asist.

Cheers.
Al.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Cell bordering

Thanks Myrna,

Didn't really register that i was referencing the cell twice.

Al.

"Myrna Larson" wrote:

See if it works correctly this way:

Dim c As Range
For Each c In Selection
With c.Borders(xlEdgeLeft)
CellThickness = .Weight
CellColorIndex = .ColorIndex
End With
With c.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = CellThickness
.ColorIndex = CellColorIndex
End With
Next c

On Tue, 12 Oct 2004 17:03:03 -0700, "Albert Jameson"
wrote:

Hi All,

I have a range (A22:A95) which has a left and right cell border.
The right cell border gets changed by other macros.
What im trying to do, is set the right border the same as left border for
each cell in the selection. Below is the code i currently have:

---------------------------------------------------------

Dim c As Range
For Each c In Selection
With c.Borders(xlEdgeLeft)
CellThickness = c.Borders.Weight
CellColorIndex = c.Borders.ColorIndex
End With
With c.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = CellThickness
.ColorIndex = CellColorIndex
End With
Next c

------------------------------------------
This code changes the right border but not to the same as the left. I.e. it
puts the line as dotted, and if the left side of the cell has a border, and
if the left side is blank, it puts in a think line on the right side of the
cell.

Can anyone please asist.

Cheers.
Al.



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 863
Default Cell bordering

Actually you were defeating the purpose of the

With c.Borders(xlEdgeLeft)

and looking at the properties of the entire borders collection. It could be
that (I haven't checked), since the borders aren't all the same, the property
is returning Null.

On Tue, 12 Oct 2004 18:09:06 -0700, "Albert Jameson"
wrote:

Thanks Myrna,

Didn't really register that i was referencing the cell twice.

Al.

"Myrna Larson" wrote:

See if it works correctly this way:

Dim c As Range
For Each c In Selection
With c.Borders(xlEdgeLeft)
CellThickness = .Weight
CellColorIndex = .ColorIndex
End With
With c.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = CellThickness
.ColorIndex = CellColorIndex
End With
Next c

On Tue, 12 Oct 2004 17:03:03 -0700, "Albert Jameson"
wrote:

Hi All,

I have a range (A22:A95) which has a left and right cell border.
The right cell border gets changed by other macros.
What im trying to do, is set the right border the same as left border for
each cell in the selection. Below is the code i currently have:

---------------------------------------------------------

Dim c As Range
For Each c In Selection
With c.Borders(xlEdgeLeft)
CellThickness = c.Borders.Weight
CellColorIndex = c.Borders.ColorIndex
End With
With c.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = CellThickness
.ColorIndex = CellColorIndex
End With
Next c

------------------------------------------
This code changes the right border but not to the same as the left. I.e.

it
puts the line as dotted, and if the left side of the cell has a border,

and
if the left side is blank, it puts in a think line on the right side of

the
cell.

Can anyone please asist.

Cheers.
Al.




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Code to copy the formulae of one cell to all the cell in the rangewith the specific cell and columnnumber changing Options Yuvraj Excel Discussion (Misc queries) 0 June 29th 09 11:20 AM
Bordering in Excell olrjr Excel Discussion (Misc queries) 2 December 31st 08 11:51 PM
Populate a cell if values in cell 1 and cell 2 match cell 3 and 4 [email protected] Excel Worksheet Functions 1 August 22nd 08 02:04 AM
line bordering hidden cells EllenM Excel Discussion (Misc queries) 2 May 11th 07 11:47 AM
How to create/run "cell A equals Cell B put Cell C info in Cell D abmb161 Excel Discussion (Misc queries) 5 January 26th 06 06:36 PM


All times are GMT +1. The time now is 08:22 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"