Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Macro to change cell borders

I have a large number of sheets with thick borders on some cells. I need to
change the borders to thin. It seems to me that this is something which could
be automated with a macro - checking each cell and changing any borders that
exist.

I have written simple macros in the past but this is beating me. Could
someone point me in the right direction.

Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
Ben Ben is offline
external usenet poster
 
Posts: 509
Default Macro to change cell borders

Sub yay()
For Each h In Sheet1.UsedRange.Cells
If h.Borders(xlDiagonalUp).Weight < xlThin Then
h.Borders(xlDiagonalUp).Weight = xlThin
If h.Borders(xlDiagonalDown).Weight < xlThin Then
h.Borders(xlDiagonalDown).Weight = xlThin
If h.Borders(xlEdgeLeft).Weight < xlThin Then h.Borders(xlEdgeLeft).Weight
= xlThin
If h.Borders(xlEdgeRight).Weight < xlThin Then
h.Borders(xlEdgeRight).Weight = xlThin
If h.Borders(xlEdgeTop).Weight < xlThin Then h.Borders(xlEdgeTop).Weight =
xlThin
If h.Borders(xlEdgeBottom).Weight < xlThin Then
h.Borders(xlEdgeBottom).Weight = xlThin
If h.Borders(xlInsideHorizontal).Weight < xlThin Then
h.Borders(xlInsideHorizontal).Weight = xlThin
If h.Borders(xlInsideVertical).Weight < xlThin Then
h.Borders(xlInsideVertical).Weight = xlThin
Next
End Sub
try that sub i tested it and it worked

"Roddie Grant" wrote:

I have a large number of sheets with thick borders on some cells. I need to
change the borders to thin. It seems to me that this is something which could
be automated with a macro - checking each cell and changing any borders that
exist.

I have written simple macros in the past but this is beating me. Could
someone point me in the right direction.

Thanks

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Macro to change cell borders

Excellent Ben. Many thanks!

Roddie
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Macro to change cell borders

Here is another possibility

Sub yay()
For Each h In ActiveSheet.UsedRange.Cells
For i = 5 To 10
If h.Borders(i).Weight < xlThin Then _
h.Borders(i).Weight = xlThin
Next
Next
End Sub

--
Regards,
Tom Ogilvy


"Roddie Grant" wrote in message
...
Excellent Ben. Many thanks!

Roddie



  #5   Report Post  
Posted to microsoft.public.excel.programming
Ben Ben is offline
external usenet poster
 
Posts: 509
Default Macro to change cell borders

ah thanks tom, i always forget that all xl constants also have a numeric twin

"Tom Ogilvy" wrote:

Here is another possibility

Sub yay()
For Each h In ActiveSheet.UsedRange.Cells
For i = 5 To 10
If h.Borders(i).Weight < xlThin Then _
h.Borders(i).Weight = xlThin
Next
Next
End Sub

--
Regards,
Tom Ogilvy


"Roddie Grant" wrote in message
...
Excellent Ben. Many thanks!

Roddie






  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Macro to change cell borders

Many thanks Tom

Roddie

"Tom Ogilvy" wrote:

Here is another possibility

Sub yay()
For Each h In ActiveSheet.UsedRange.Cells
For i = 5 To 10
If h.Borders(i).Weight < xlThin Then _
h.Borders(i).Weight = xlThin
Next
Next
End Sub

--
Regards,
Tom Ogilvy


"Roddie Grant" wrote in message
...
Excellent Ben. Many thanks!

Roddie




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
How do you change the preset borders on the Formating Tool bar? wfmcguigan Excel Discussion (Misc queries) 2 February 5th 10 09:05 PM
How can I change the color/type of the borders I put on cells? Tourkow Excel Discussion (Misc queries) 8 November 25th 09 04:42 PM
How do I change the default color for borders in Excel 2003? Sheila Excel Discussion (Misc queries) 4 December 11th 08 07:56 PM
macro that will change the font of a cell if i change a value jk Excel Discussion (Misc queries) 2 July 29th 08 04:39 PM
Button to change borders dixonpeter Excel Discussion (Misc queries) 2 August 12th 05 01:30 PM


All times are GMT +1. The time now is 03:47 PM.

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

About Us

"It's about Microsoft Excel"