Get Border Range

sheen

New Member
Joined
Sep 14, 2006
Messages
3
Hi,

I have more than one data tables on a sheet, each with a border. I want to write a macro that colors all these tables. For this i need, to get the range with borders. Is there any way to do this?

Thanks!
 

Some videos you may like

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.

SydneyGeek

MrExcel MVP
Joined
Aug 5, 2003
Messages
12,251
To select an entire table in code, do this:

1. Select the cell
2. Activecell.CurrentRegion.Select

If you want the table's background to be yellow, try
ActiveCell.CurrentRegion.Interior.ColorIndex=6

Denis
 

Joe Was

MrExcel MVP
Joined
Feb 19, 2002
Messages
7,539
Select all the cells in one table at a time, then name the range:

Excel Toolbar: Insert - Name - Define...
Then in the top box add the name you want to give that table.

Now you can refer to the collection of cells in that table by its name. If the table changes in size the name will automatically refer to all the cells in that table.

You will need to color the range using VBA Event code. So, if say the value of a cell changes value, then that value will trigger what color the table gets. Or you can use, some other trigger or condition to color that table. This has been done many times on this board, use the "Search" utility at the top right of this board to search for code samples.
 

Watch MrExcel Video

Forum statistics

Threads
1,108,509
Messages
5,523,313
Members
409,511
Latest member
hitesh222002

This Week's Hot Topics

Top