View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Roger Whitehead[_2_] Roger Whitehead[_2_] is offline
external usenet poster
 
Posts: 28
Default Delete Columns if rows 8 & 9 are blank and place border

Hi manfareed, try the following. This assumes Excel to 2003, and that at
least the last row of the sheet is empty

Sub deleteCols()
Rows(1).Insert
Set myrange = Range("E1:IV1")
myrange.FormulaR1C1 = "=IF(AND(LEN(R9C)=0,LEN(R10C)=0),1,"""")"
myrange.Value = myrange.Value
myrange.SpecialCells(xlCellTypeConstants, xlNumbers).EntireColumn.Delete

'Loop for now, but could Select A1 and save WB, then use special cells to
find LastCell
For c = 255 To 1 Step -1
If Application.WorksheetFunction.CountA(Range(Cells(2 , c), Cells(65536,
c))) < 0 Then
lastcol = c
Exit For
End If
Next

Rows(1).Delete
Range(Cells(6, 5), Cells(10, lastcol)).BorderAround , xlThick,
xlColorIndexAutomatic
End Sub


---
HTH
Roger
Shaftesbury (UK)


"manfareed" wrote in message
...
Hi

I wish to delete columns from column "E" onwards which have no value on
rows
8 and 9. Also I would like to place a "thick box border" around rows 6 to
10
up to the and including the last column with data.

Thanks