Click here to Skip to main content
15,917,481 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how can i select different and separate ranges of cells on the same time .

SQL
Dim SelectionRange As Excel.Range
SelectionRange = xlWorkSheet.Range("A1","k1")
       SelectionRange.BorderAround(Excel.XlLineStyle.xlContinuous, Excel.XlBorderWeight.xlMedium, Excel.XlColorIndex.xlColorIndexAutomatic, Excel.XlColorIndex.xlColorIndexAutomatic)


i am using the above many times to format the excel sheet. is there a way to make multiple selection to save 10's of codes lines.
i don't know why IntelliSense is not working for most of excel functions.
Posted

1 solution

the only way that i can do is just

SQL
SelectionRange = xlWorkSheet.Range("A5:k5")
       SelectionRange2 = xlWorkSheet.Range("A10:k10")
       UnionRange = xlApp.Union(SelectionRange, SelectionRange2)
       UnionRange.BorderAround(Excel.XlLineStyle.xlContinuous, Excel.XlBorderWeight.xlMedium, Excel.XlColorIndex.xlColorIndexAutomatic, Excel.XlColorIndex.xlColorIndexAutomatic)


anything easier than this...
 
Share this answer
 
Comments
Ahmed.ganainy 19-Feb-13 1:59am    
and the problem of Union that if i have two borders next to each other it will become one surround borders without the intersection line in between......

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900