Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 72
Default Deleting all rows in all sheets

I have a workbook with multiple sheets and I need to delete all rows in each
sheet after the total row. The total row shows "Total" in the first column
and it is in a different row in each sheet. Can anyone help?
--
Thank you, Jodie
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default Deleting all rows in all sheets

Hi Jodie

Try the below

Sub Macro()
Dim ws As Worksheet, lngLastRow As Long
For Each ws In Worksheets
lngLastRow = ws.Cells.Find(What:="*", _
SearchDirection:=xlPrevious, SearchOrder:=xlRows).Row
Set varFound = ws.Columns(1).Find("Total", , xlValues, 1)
If Not varFound Is Nothing Then
ws.Rows(varFound.Row + 1 & ":" & lngLastRow).Delete
End If
Next
End Sub

If this post helps click Yes
---------------
Jacob Skaria


"Jodie" wrote:

I have a workbook with multiple sheets and I need to delete all rows in each
sheet after the total row. The total row shows "Total" in the first column
and it is in a different row in each sheet. Can anyone help?
--
Thank you, Jodie

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 72
Default Deleting all rows in all sheets

It worked, thank you very much.
--
Jodie


"Jacob Skaria" wrote:

Hi Jodie

Try the below

Sub Macro()
Dim ws As Worksheet, lngLastRow As Long
For Each ws In Worksheets
lngLastRow = ws.Cells.Find(What:="*", _
SearchDirection:=xlPrevious, SearchOrder:=xlRows).Row
Set varFound = ws.Columns(1).Find("Total", , xlValues, 1)
If Not varFound Is Nothing Then
ws.Rows(varFound.Row + 1 & ":" & lngLastRow).Delete
End If
Next
End Sub

If this post helps click Yes
---------------
Jacob Skaria


"Jodie" wrote:

I have a workbook with multiple sheets and I need to delete all rows in each
sheet after the total row. The total row shows "Total" in the first column
and it is in a different row in each sheet. Can anyone help?
--
Thank you, Jodie

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Deleting all rows in all sheets


Give this macro a try...

Sub DeleteBelowTotalRow()
On Error Resume Next
Intersect(Range("A" & (Columns("A").Find("Total").Row + 1) & ":A" & _
Rows.Count), ActiveSheet.UsedRange).EntireRow.Delete
End Sub

--
Rick (MVP - Excel)


"Jodie" wrote in message
...
I have a workbook with multiple sheets and I need to delete all rows in
each
sheet after the total row. The total row shows "Total" in the first
column
and it is in a different row in each sheet. Can anyone help?
--
Thank you, Jodie


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Deleting all rows in all sheets

Whoops... you said "all sheets" didn't you?

Sub DeleteBelowTotalRow()
Dim WS As Worksheet
On Error Resume Next
For Each WS In Worksheets
Intersect(WS.Range("A" & (WS.Columns("A").Find("Total").Row + 1) & _
":A" & WS.Rows.Count), WS.UsedRange).EntireRow.Delete
Next
End Sub

--
Rick (MVP - Excel)


"Rick Rothstein" wrote in message
...
Give this macro a try...

Sub DeleteBelowTotalRow()
On Error Resume Next
Intersect(Range("A" & (Columns("A").Find("Total").Row + 1) & ":A" & _
Rows.Count), ActiveSheet.UsedRange).EntireRow.Delete
End Sub

--
Rick (MVP - Excel)


"Jodie" wrote in message
...
I have a workbook with multiple sheets and I need to delete all rows in
each
sheet after the total row. The total row shows "Total" in the first
column
and it is in a different row in each sheet. Can anyone help?
--
Thank you, Jodie





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
disable from deleting rows; folders not to delete; sheets to inser CAPTGNVR[_2_] Excel Programming 2 October 21st 09 10:33 AM
Deleting rows from mutliple sheets diba Excel Programming 1 August 16th 07 05:57 PM
Deleting rows from all sheets in an array? AVR Excel Programming 1 January 31st 07 04:26 PM
inserting deleting rows?how do i get the other sheets to do the sa cunningham82 Excel Discussion (Misc queries) 0 December 27th 06 09:51 PM
Updating, Deleting and inserting rows over two Excel Sheets Dilip Mistry Excel Worksheet Functions 0 July 25th 05 07:09 PM


All times are GMT +1. The time now is 09:44 AM.

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"