Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 54
Default Delete rows at the same time from selected worksheets

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.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Delete rows at the same time from selected worksheets

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" wrote in message
...
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.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Delete rows at the same time from selected worksheets

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


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default Delete rows at the same time from selected worksheets

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

"Filo" wrote in message
...
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
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 row and 3 rows below by range selected Corey Excel Programming 2 November 28th 06 08:14 AM
Delete non-contiguous selected rows Barbara Ryan Excel Programming 8 May 9th 06 08:58 PM
Delete same Rows/Columns from two worksheets at a time Vinit[_2_] Excel Programming 2 May 14th 05 04:20 AM
Delete non-selected rows SparePersn Excel Programming 2 December 21st 04 02:57 PM
Delete Selected Rows Ken[_18_] Excel Programming 2 February 5th 04 10:33 PM


All times are GMT +1. The time now is 05:57 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"