Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default How do I delete rows and columns in With With End Loop?

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


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 135
Default How do I delete rows and columns in With With End Loop?

Bob,

Turn on the macro recorder and do the operation manually. Then look at the
recorded macro and you will see something like this:

Columns("A:H").Select
ActiveWindow.SmallScroll Down:=-3
Selection.Delete Shift:=xlToLeft
Rows("1:1").Select
ActiveWindow.SmallScroll Down:=36
Rows("1:59").Select
Selection.Delete Shift:=xlUp
Range("A1").Select

You can then edit these lines to this:

Columns("A:H").Delete Shift:=xlToLeft
Rows("1:59").Delete Shift:=xlUp

Within the With clause it will look like this:

With wbk2.Sheets(1)
.Cells.ClearFormats
.Cells(1, 1).Select
.Columns.ColumnWidth = 11
.Rows.RowHeight = 12
.Columns("A:H").Delete Shift:=xlToLeft
.Rows("1:59").Delete Shift:=xlUp
End With

HTH,
Shockley


"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




  #3   Report Post  
Posted to microsoft.public.excel.programming
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




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default How do I delete rows and columns in With With End Loop?

Shockley and Tom,

Thank you for the help.
Regards,
Bob

"shockley" wrote in message
...
Bob,

Turn on the macro recorder and do the operation manually. Then look at the
recorded macro and you will see something like this:

Columns("A:H").Select
ActiveWindow.SmallScroll Down:=-3
Selection.Delete Shift:=xlToLeft
Rows("1:1").Select
ActiveWindow.SmallScroll Down:=36
Rows("1:59").Select
Selection.Delete Shift:=xlUp
Range("A1").Select

You can then edit these lines to this:

Columns("A:H").Delete Shift:=xlToLeft
Rows("1:59").Delete Shift:=xlUp

Within the With clause it will look like this:

With wbk2.Sheets(1)
.Cells.ClearFormats
.Cells(1, 1).Select
.Columns.ColumnWidth = 11
.Rows.RowHeight = 12
.Columns("A:H").Delete Shift:=xlToLeft
.Rows("1:59").Delete Shift:=xlUp
End With

HTH,
Shockley


"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






Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Delete rows with more or less than 7 columns Keith New Users to Excel 8 May 22nd 09 10:26 AM
Query to delete rows or columns kilo Excel Discussion (Misc queries) 2 April 3rd 08 12:51 PM
How to Delete Rows in Excel In a Do Loop indraneel Excel Worksheet Functions 6 September 15th 06 09:51 AM
Delete rows that contain blank columns Lindsey Excel Worksheet Functions 1 December 8th 05 10:34 PM
Delete columns or rows Ivor Williams Excel Worksheet Functions 2 June 3rd 05 11:16 PM


All times are GMT +1. The time now is 01:29 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"