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!
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.

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.
 

Forum statistics

Threads
1,141,222
Messages
5,705,109
Members
421,378
Latest member
CarlosDuran

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top