PC Review


Reply
Thread Tools Rate Thread

Deleting all rows in all sheets

 
 
Jodie
Guest
Posts: n/a
 
      9th Nov 2009
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 With Quote
 
 
 
 
Jacob Skaria
Guest
Posts: n/a
 
      9th Nov 2009
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

 
Reply With Quote
 
Jodie
Guest
Posts: n/a
 
      9th Nov 2009
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

 
Reply With Quote
 
Rick Rothstein
Guest
Posts: n/a
 
      9th Nov 2009

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" <(E-Mail Removed)> wrote in message
news:59F965FD-D2A8-4EDB-816F-(E-Mail Removed)...
>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 With Quote
 
Rick Rothstein
Guest
Posts: n/a
 
      9th Nov 2009
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
> news:59F965FD-D2A8-4EDB-816F-(E-Mail Removed)...
>>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 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
Deleting rows from mutliple sheets diba Microsoft Excel Programming 1 16th Aug 2007 05:57 PM
Deleting rows from all sheets in an array? =?Utf-8?B?QVZS?= Microsoft Excel Programming 1 31st Jan 2007 04:26 PM
Updating, Deleting and inserting rows over two Excel Sheets Dilip Mistry Microsoft Excel Worksheet Functions 0 25th Jul 2005 07:09 PM
Updating, Deleting and inserting rows over two Excel Sheets mem Microsoft Excel Discussion 2 25th Jul 2005 12:48 PM
Deleting rows in a workbook though all coresponding sheets =?Utf-8?B?RGF2ZSBCYXRlcw==?= Microsoft Excel Misc 2 8th Feb 2004 10:01 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:55 PM.