View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default How do I delete rows and columns in With With End Loop?

A different interpretation:

by delete do you mean to clear?

With wbk2.Sheets(1).Columns("A:H")
.Cells.Clear
.EntireColumn.ColumnWidth = 11
End With
With wbk2.Sheets(1).rows("1:59")
.Cells.Clear
.EntireRow.RowHeight = 12
End With

or if you are talking the intersection (A1:H59)

With wbk2.Sheets(1).Columns("A1:H59")
.Cells.Clear
.EntireRow.RowHeight = 12
.EntireColumn.ColumnWidth = 11
End With

Replace .clear with .clearcontents to keep formats

if you actually mean delete

With wbk2.Sheets(1)
.Rows("1:59").EntireRow.Delete
.Columns("A:H").EntireColumn.Delete
End With


--
Regards,
Tom Ogilvy

Bob Benjamin wrote in message
...
How do I have to modify the loop below in order
to delete columns A to H and rows 1 to 59 in wbk2?

With wbk2.Sheets(1)
.Cells.ClearFormats
.Cells(1, 1).Select
.Columns.ColumnWidth = 11
.Rows.RowHeight = 12
End With

Any help would be appreciated.

Bob