-1

I need some help.

What I need is a code for colorid the Grid in Excel in this way:

  • find the first cell with value ( 1 )
  • find the last cell with value ( 2 )
  • range (1:2)
  • Color the grid black

My code by now:

'Color the columns A to K and ALL the rows below, no matter if they have a value or not.    
xlWorkSheet.Range(xlWorkSheet.Cells(1, 1), xlWorkSheet.Cells(xlWorkSheet.Rows.Count, 11)).Borders.ColorIndex = 0

I need to change the color of not-empty rows .

THX

nbadaud
  • 694
  • 7
  • 26
Gest1979
  • 1
  • 1

1 Answers1

0

Find the first cell :

You should active the first cell (A1) and use IsEmpty function. Then you loop in the same column until you find a cell containing a value.

By the way, you need to keep the number of this row for the second point.

Find the last cell :

You have to exit your loop when it finds a new empty row. Then you'll get the range of cells using the number of first and last row.

You can check the MSDN - "Empty Cells" to get more details.

nbadaud
  • 694
  • 7
  • 26