 | Junior Member with 22 posts. | | Join Date: Jul 2009 Experience: Beginner | | Solved: Border Macro Hi,
Does anyone know the code for a macro to put borders around any cell with data in it? this needs to be the border which cover's the edge of every cell.
There are three sheets i need this for each sheet has data from column a to column N.
If you require anymore info please do ask.
Thanks
Ashley | | Senior Member with 123 posts. | | Join Date: May 2009 Location: Nottingham, UK Experience: It depends | | I think the easiest way to achieve this is using conditional formatting - you can create a rule that has outside border on cell if not blank.
If 2007 the Highlight the cells you want affected (probably have to do it once per sheet)
Conditional Formatting (On the Home Tab) > New Rule > Format only cells that contain > Change the 'Cell Value' to 'No Blanks' > Click on Format > Borders > Outside Borders
This should achieve what you want.
Let me know if you are using a different version and/or it doesn't make sense,
Cheers
__________________ From the darkness.... There Came.... A Torch! | | Junior Member with 22 posts. | | Join Date: Jul 2009 Experience: Beginner | | Hi i have already set up the sheet to use 3 conditional formatting options for a RAG (red amber gree) status check. Can this be done using VB worksheet code? Any other suggestions?
Thanks | | Distinguished Member with 7,166 posts. | | Join Date: Jul 2005 Location: The void AKA edge of the Fens Experience: I bent my wookie :( | | In this case, just use the macro recorder.
Start the recorder, enter a "useful" name, click OK.
Press F5, click Special, select "Constants", click OK.
Select the "All borders" border option, click OK.
Click Stop Recording.
(then record another one for cells with formulas if you need to) | | Junior Member with 22 posts. | | Join Date: Jul 2009 Experience: Beginner | | Hi bomb,
appreciate the help. This will allow me to have boarders only around cells with data in? im working on xl2003
Thanks | | Senior Member with 123 posts. | | Join Date: May 2009 Location: Nottingham, UK Experience: It depends | | Sorry im only just getting back to you Code: Sub Borders()
' Borders Macro
Selection.SpecialCells(xlCellTypeConstants, 23).Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
Selection.Borders(xlInsideVertical).LineStyle = xlNone
Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
End Sub
| | Junior Member with 22 posts. | | Join Date: Jul 2009 Experience: Beginner | | thats cool is this just the code for border or does it include the code required to ensure borders only appear in cells with data in them?
thanks | | Senior Member with 123 posts. | | Join Date: May 2009 Location: Nottingham, UK Experience: It depends | | It does it all, it selects cells with data and then applies the border to them | | Junior Member with 22 posts. | | Join Date: Jul 2009 Experience: Beginner | | Hi,
Works fine excaept the line of code .TintAndShade = 0 causes a debug error, when i remove this line though in all of the places it appears it then works fine.
I do have one issue with this though, the code seems to draw a border around all data. For example i have data in A34 and A35, it draws a border around both these cells (an outside border), i really require the all borders type, is this possible? What part of the code do i need to change?
Thanks you apart from that issue its perfect. | | Junior Member with 1 posts. | | Join Date: Aug 2009 Location: Ankara Experience: Advanced |
11-Aug-2009, 07:50 AM
#10 | Hi Ashley,
you can simply modify the last two lines of Jubbaloo's beautiful macro by replacing "xlNone" by "xlContinuous". You should get exactly what you requested.
Kind regards, | | Junior Member with 22 posts. | | Join Date: Jul 2009 Experience: Beginner |
12-Aug-2009, 12:03 PM
#11 | Thank you all i will now close the thread. |  THIS THREAD HAS EXPIRED.
Are you having the same problem?
We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.
|
Smart Search
| Find your solution! | |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | | |  WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who want to help you solve your computer problems. See our Welcome Guide to get started.
| You Are Using: |
Advertisements do not imply our endorsement of that product or service.
All times are GMT -5. The time now is 03:30 AM.
Copyright © 1996 - 2009 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd. | |
|