SonicBoomAu Posted January 18, 2005 Posted January 18, 2005 Hi All, I am able to place a border around a selected area within Excel but I can not figure out how to place borders inside a selection. I.E. ' Border around Selection objSheet.Range("B6:E55").BorderAround() ' Border Inside Selected objSheet.Range("B6:E55").BorderInside() ???? Any ideas welcome. Quote Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. -- Rick Cook, The Wizardry Compiled
Mike_R Posted January 24, 2005 Posted January 24, 2005 Hey Sonic, Sorry I missed this one... what do you mean "boaders inside". Borders are really sort of "Interior" already, altohugh, they do show up graphically as "around". That is, Cell A1's right border looks exactly the same as Cell B1's left border, but A1's really is to the left of B1's, even if they look identical. Can you explain further what you mean/want here, or have you figured it out..? -- Mike Quote Posting Guidelines Avatar by Lebb
SonicBoomAu Posted January 24, 2005 Author Posted January 24, 2005 Mike, What I require is the inside borders. When I use the .borderaround command. It just does the outside edge, no the interior borders / lines. I.E. ' Border around Selection objSheet.Range("B6:E55").BorderAround() Have a look at the attachment as it will give you a better idea of what I require. A picture is worth a thousand words. :) SonicBorder Example.zip Quote Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. -- Rick Cook, The Wizardry Compiled
Mike_R Posted January 25, 2005 Posted January 25, 2005 To get the interior lines, you can use something like the following: Dim myRange As Excel.Range = objSheet.Range("B6:E55") myRange.BorderAround(ColorIndex:=xlAutomatic, Weight:=xlThin) With myRange.Borders(xlInsideVertical) .LineStyle = xlContinuous .Weight = xlThin .ColorIndex = xlAutomatic End With With myRange.Borders(xlInsideHorizontal) .LineStyle = xlContinuous .Weight = xlThin .ColorIndex = xlAutomatic End With Note that myRange.Borders(xlInsideHorizontal) and myRange.Borders(xlInsideVertical) will throw an exception if the myRange is only a single cell. So I would add some error handling to this... Good luck! :), Mike Quote Posting Guidelines Avatar by Lebb
SonicBoomAu Posted January 26, 2005 Author Posted January 26, 2005 Hi Mike, Thanks for the helping hand. That worked well I just had to put in the full paths. I.E. With myRangePage1.Borders(Excel.XlBordersIndex.xlInsideVertical) .LineStyle = [color=Navy]Excel.XlLineStyle.xlContinuous[/color] .Weight = [color=Navy]Excel.XlBorderWeight.xlThin[/color] .ColorIndex = [color=Navy]Excel.XlColorIndex.xlColorIndexAutomatic[/color] End With With myRangePage1.Borders(Excel.XlBordersIndex.xlInsideHorizontal) .LineStyle = [color=Navy]Excel.XlLineStyle.xlContinuous[/color] .Weight = [color=Navy]Excel.XlBorderWeight.xlThin[/color] .ColorIndex = [color=Navy]Excel.XlColorIndex.xlColorIndexAutomatic[/color] End With Once again thanks for your Help Quote Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. -- Rick Cook, The Wizardry Compiled
Mike_R Posted January 27, 2005 Posted January 27, 2005 Yeah, I apologize... I was being a little lazy. I really just quickly cleaned up some Macro Recorder code (VBA) and didn't bother looking up the necessary Imports statements. Looks like 3, eh?Imports Excel.XlLineStyle Imports Excel.XlBorderWeight Imports Excel.XlColorIndex Glad you got it. :) Quote Posting Guidelines Avatar by Lebb
Recommended Posts