PC Review


Reply
Thread Tools Rate Thread

Delete rows at the same time from selected worksheets

 
 
=?Utf-8?B?Rmlsbw==?=
Guest
Posts: n/a
 
      5th May 2007
I tried to write VB code that selects four worksheets, and then deletes rows
3 to 4, but what happens is that it only deletes the data from the active
worksheet. If we use VB code, do we just have the option to perform the
deletion one worksheet at a time, or is there a way to do the deletion on all
four worksheets at the same time?

Thank you.
 
Reply With Quote
 
 
 
 
Norman Jones
Guest
Posts: n/a
 
      5th May 2007
Hi Filo,

I think that it would be nevessary to cycle throrgh the
sheets of interest.

For example, try something like:

'=============>>
Public Sub Tester()
Dim WB As Workbook
Dim SH As Worksheet

Set WB = ActiveWorkbook '<<===== CHANGE

For Each SH In WB.Worksheets
SH.Rows("3:4").Delete
Next SH
End Sub
'<<=============


---
Regards,
Norman


"Filo" <(E-Mail Removed)> wrote in message
news:9E60B15B-61F9-4752-8FF2-(E-Mail Removed)...
>I tried to write VB code that selects four worksheets, and then deletes
>rows
> 3 to 4, but what happens is that it only deletes the data from the active
> worksheet. If we use VB code, do we just have the option to perform the
> deletion one worksheet at a time, or is there a way to do the deletion on
> all
> four worksheets at the same time?
>
> Thank you.



 
Reply With Quote
 
Norman Jones
Guest
Posts: n/a
 
      5th May 2007
> I think that it would be nevessary to cycle throrgh the
> sheets of interest.


==>

I think that it would be necessary to cycle through the
sheets of interest.



---
Regards,
Norman


 
Reply With Quote
 
Don Guillett
Guest
Posts: n/a
 
      5th May 2007
the macro recorder is your friend
Sub Macro1()
'
' Macro1 Macro
' Macro recorded 5/5/2007 by Donald B. Guillett
'

'
Sheets(Array("Sheet2", "Sheet3")).Select
Sheets("Sheet3").Activate
Rows("3:4").Select
Selection.Delete Shift:=xlUp
Sheets("Sheet1").Select
End Sub
but a for/next might even be better

for each ws in worksheets
if ws.name <> "keepthisone" then ws.rows("3:4").delete
next ws

--
Don Guillett
SalesAid Software
(E-Mail Removed)
"Filo" <(E-Mail Removed)> wrote in message
news:9E60B15B-61F9-4752-8FF2-(E-Mail Removed)...
>I tried to write VB code that selects four worksheets, and then deletes
>rows
> 3 to 4, but what happens is that it only deletes the data from the active
> worksheet. If we use VB code, do we just have the option to perform the
> deletion one worksheet at a time, or is there a way to do the deletion on
> all
> four worksheets at the same time?
>
> Thank you.


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Delete Selected Worksheets Macro Indianagreg Microsoft Excel Programming 3 31st Dec 2008 02:20 PM
Delete selected worksheets Casey Microsoft Excel Programming 4 14th Nov 2008 09:48 AM
Delete same Rows/Columns from two worksheets at a time Vinit Microsoft Excel Programming 2 14th May 2005 04:20 AM
Adding selected rows from several worksheets to a summary worksheet John Microsoft Excel Worksheet Functions 1 21st Jun 2004 08:26 PM
Create individual worksheets for selected rows in a table Batman2002 Microsoft Excel Discussion 4 16th Oct 2003 05:44 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:13 PM.