Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 9
Default Filtering or deleting multiple rows

I'm not exactly a new user, but this is the first time in a while that I've
had to apply this knowledge to my professional duties. The spreadsheet I'm
working on is considerably large and I need to retain rows that contain
certain text or specific criteria. For example, I only need items A, C, H,
and P, and Z out of a document that has everything else (i don't need) in
between. How do I delete based on specific criteria (letter, city name,)
withouth scrolling down and sifting through it manually? Please help me.
  #2   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 11,123
Default Filtering or deleting multiple rows

Start here
http://www.rondebruin.nl/delete.htm

For example try this one

This will check column A (Change it to the column you want)
'We check the values in the A column in this example
With .Cells(Lrow, "A")

Add the other values to the array in the macro

If IsError(Application.Match(.Value, _
Array("A", "C", "H"), 0)) Then .EntireRow.Delete

You can also add a list of values on another worksheet if you find that easy ?



Sub Loop_Example()
Dim Firstrow As Long
Dim Lastrow As Long
Dim Lrow As Long
Dim CalcMode As Long
Dim ViewMode As Long

With Application
CalcMode = .Calculation
.Calculation = xlCalculationManual
.ScreenUpdating = False
End With

'We use the ActiveSheet but you can replace this with
'Sheets("MySheet")if you want
With ActiveSheet

'We select the sheet so we can change the window view
.Select

'If you are in Page Break Preview Or Page Layout view go
'back to normal view, we do this for speed
ViewMode = ActiveWindow.View
ActiveWindow.View = xlNormalView

'Turn off Page Breaks, we do this for speed
.DisplayPageBreaks = False

'Set the first and last row to loop through
Firstrow = .UsedRange.Cells(1).Row
Lastrow = .UsedRange.Rows(.UsedRange.Rows.Count).Row

'We loop from Lastrow to Firstrow (bottom to top)
For Lrow = Lastrow To Firstrow Step -1

'We check the values in the A column in this example
With .Cells(Lrow, "A")

If Not IsError(.Value) Then

If IsError(Application.Match(.Value, _
Array("A", "C", "H"), 0)) Then .EntireRow.Delete

End If

End With

Next Lrow

End With

ActiveWindow.View = ViewMode
With Application
.ScreenUpdating = True
.Calculation = CalcMode
End With

End Sub


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Determined07" wrote in message ...
I'm not exactly a new user, but this is the first time in a while that I've
had to apply this knowledge to my professional duties. The spreadsheet I'm
working on is considerably large and I need to retain rows that contain
certain text or specific criteria. For example, I only need items A, C, H,
and P, and Z out of a document that has everything else (i don't need) in
between. How do I delete based on specific criteria (letter, city name,)
withouth scrolling down and sifting through it manually? Please help me.

  #3   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 9
Default Filtering or deleting multiple rows

Thanks for that. I need to delete the rows if a specific value does NOT
exist. The amount of items that I need to delete is greater than those I need
to retain, so it will be simpler to eliminate that bulk all at once. How do I
do that? Please help me...there's this project going on and I've been so
frustrated.

Also, once it's deleted, I need to add a new column with text to
corresponding with the remaining text (that I retained) from the other column.

for example: F7 to F765 and j7 to j765 should be consistent with eachother.
I really feel at a loss.

"Ron de Bruin" wrote:

Start here
http://www.rondebruin.nl/delete.htm

For example try this one

This will check column A (Change it to the column you want)
'We check the values in the A column in this example
With .Cells(Lrow, "A")

Add the other values to the array in the macro

If IsError(Application.Match(.Value, _
Array("A", "C", "H"), 0)) Then .EntireRow.Delete

You can also add a list of values on another worksheet if you find that easy ?



Sub Loop_Example()
Dim Firstrow As Long
Dim Lastrow As Long
Dim Lrow As Long
Dim CalcMode As Long
Dim ViewMode As Long

With Application
CalcMode = .Calculation
.Calculation = xlCalculationManual
.ScreenUpdating = False
End With

'We use the ActiveSheet but you can replace this with
'Sheets("MySheet")if you want
With ActiveSheet

'We select the sheet so we can change the window view
.Select

'If you are in Page Break Preview Or Page Layout view go
'back to normal view, we do this for speed
ViewMode = ActiveWindow.View
ActiveWindow.View = xlNormalView

'Turn off Page Breaks, we do this for speed
.DisplayPageBreaks = False

'Set the first and last row to loop through
Firstrow = .UsedRange.Cells(1).Row
Lastrow = .UsedRange.Rows(.UsedRange.Rows.Count).Row

'We loop from Lastrow to Firstrow (bottom to top)
For Lrow = Lastrow To Firstrow Step -1

'We check the values in the A column in this example
With .Cells(Lrow, "A")

If Not IsError(.Value) Then

If IsError(Application.Match(.Value, _
Array("A", "C", "H"), 0)) Then .EntireRow.Delete

End If

End With

Next Lrow

End With

ActiveWindow.View = ViewMode
With Application
.ScreenUpdating = True
.Calculation = CalcMode
End With

End Sub


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Determined07" wrote in message ...
I'm not exactly a new user, but this is the first time in a while that I've
had to apply this knowledge to my professional duties. The spreadsheet I'm
working on is considerably large and I need to retain rows that contain
certain text or specific criteria. For example, I only need items A, C, H,
and P, and Z out of a document that has everything else (i don't need) in
between. How do I delete based on specific criteria (letter, city name,)
withouth scrolling down and sifting through it manually? Please help me.


  #4   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 11,123
Default Filtering or deleting multiple rows

Hi Determined07

Thanks for that. I need to delete the rows if a specific value does NOT

The macro do that

If IsError(Application.Match

If Not IsError(Application.Match ...........delete the items in the array

to retain, so it will be simpler to eliminate that bulk all at once


AutoFilter have a maximum of 2 criteria

Advanced filer is another option but you must add the values in a range
Start here
http://www.contextures.com/xladvfilter01.html


With my example above you can also fill in the values in a range
'Replace Array("A", "C", "H") with Sheets("Sheet1").Range("A1:A200")

There is also a Union example on my site that is faster if it is a large range


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Determined07" wrote in message ...
Thanks for that. I need to delete the rows if a specific value does NOT
exist. The amount of items that I need to delete is greater than those I need
to retain, so it will be simpler to eliminate that bulk all at once. How do I
do that? Please help me...there's this project going on and I've been so
frustrated.

Also, once it's deleted, I need to add a new column with text to
corresponding with the remaining text (that I retained) from the other column.

for example: F7 to F765 and j7 to j765 should be consistent with eachother.
I really feel at a loss.

"Ron de Bruin" wrote:

Start here
http://www.rondebruin.nl/delete.htm

For example try this one

This will check column A (Change it to the column you want)
'We check the values in the A column in this example
With .Cells(Lrow, "A")

Add the other values to the array in the macro

If IsError(Application.Match(.Value, _
Array("A", "C", "H"), 0)) Then .EntireRow.Delete

You can also add a list of values on another worksheet if you find that easy ?



Sub Loop_Example()
Dim Firstrow As Long
Dim Lastrow As Long
Dim Lrow As Long
Dim CalcMode As Long
Dim ViewMode As Long

With Application
CalcMode = .Calculation
.Calculation = xlCalculationManual
.ScreenUpdating = False
End With

'We use the ActiveSheet but you can replace this with
'Sheets("MySheet")if you want
With ActiveSheet

'We select the sheet so we can change the window view
.Select

'If you are in Page Break Preview Or Page Layout view go
'back to normal view, we do this for speed
ViewMode = ActiveWindow.View
ActiveWindow.View = xlNormalView

'Turn off Page Breaks, we do this for speed
.DisplayPageBreaks = False

'Set the first and last row to loop through
Firstrow = .UsedRange.Cells(1).Row
Lastrow = .UsedRange.Rows(.UsedRange.Rows.Count).Row

'We loop from Lastrow to Firstrow (bottom to top)
For Lrow = Lastrow To Firstrow Step -1

'We check the values in the A column in this example
With .Cells(Lrow, "A")

If Not IsError(.Value) Then

If IsError(Application.Match(.Value, _
Array("A", "C", "H"), 0)) Then .EntireRow.Delete

End If

End With

Next Lrow

End With

ActiveWindow.View = ViewMode
With Application
.ScreenUpdating = True
.Calculation = CalcMode
End With

End Sub


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Determined07" wrote in message
...
I'm not exactly a new user, but this is the first time in a while that I've
had to apply this knowledge to my professional duties. The spreadsheet I'm
working on is considerably large and I need to retain rows that contain
certain text or specific criteria. For example, I only need items A, C, H,
and P, and Z out of a document that has everything else (i don't need) in
between. How do I delete based on specific criteria (letter, city name,)
withouth scrolling down and sifting through it manually? Please help me.



  #5   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 9
Default Filtering or deleting multiple rows

instead of editing the initial document and deleting from that particular
worksheet, would it be better (think in terms of a new user) to create a
whole new worksheet altogether, and pull the data that meets the criteria? If
that's recommended, please tell me how to do that. Thanks, you've been a
great help.

"Ron de Bruin" wrote:

Hi Determined07

Thanks for that. I need to delete the rows if a specific value does NOT

The macro do that

If IsError(Application.Match

If Not IsError(Application.Match ...........delete the items in the array

to retain, so it will be simpler to eliminate that bulk all at once


AutoFilter have a maximum of 2 criteria

Advanced filer is another option but you must add the values in a range
Start here
http://www.contextures.com/xladvfilter01.html


With my example above you can also fill in the values in a range
'Replace Array("A", "C", "H") with Sheets("Sheet1").Range("A1:A200")

There is also a Union example on my site that is faster if it is a large range


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Determined07" wrote in message ...
Thanks for that. I need to delete the rows if a specific value does NOT
exist. The amount of items that I need to delete is greater than those I need
to retain, so it will be simpler to eliminate that bulk all at once. How do I
do that? Please help me...there's this project going on and I've been so
frustrated.

Also, once it's deleted, I need to add a new column with text to
corresponding with the remaining text (that I retained) from the other column.

for example: F7 to F765 and j7 to j765 should be consistent with eachother.
I really feel at a loss.

"Ron de Bruin" wrote:

Start here
http://www.rondebruin.nl/delete.htm

For example try this one

This will check column A (Change it to the column you want)
'We check the values in the A column in this example
With .Cells(Lrow, "A")

Add the other values to the array in the macro

If IsError(Application.Match(.Value, _
Array("A", "C", "H"), 0)) Then .EntireRow.Delete

You can also add a list of values on another worksheet if you find that easy ?



Sub Loop_Example()
Dim Firstrow As Long
Dim Lastrow As Long
Dim Lrow As Long
Dim CalcMode As Long
Dim ViewMode As Long

With Application
CalcMode = .Calculation
.Calculation = xlCalculationManual
.ScreenUpdating = False
End With

'We use the ActiveSheet but you can replace this with
'Sheets("MySheet")if you want
With ActiveSheet

'We select the sheet so we can change the window view
.Select

'If you are in Page Break Preview Or Page Layout view go
'back to normal view, we do this for speed
ViewMode = ActiveWindow.View
ActiveWindow.View = xlNormalView

'Turn off Page Breaks, we do this for speed
.DisplayPageBreaks = False

'Set the first and last row to loop through
Firstrow = .UsedRange.Cells(1).Row
Lastrow = .UsedRange.Rows(.UsedRange.Rows.Count).Row

'We loop from Lastrow to Firstrow (bottom to top)
For Lrow = Lastrow To Firstrow Step -1

'We check the values in the A column in this example
With .Cells(Lrow, "A")

If Not IsError(.Value) Then

If IsError(Application.Match(.Value, _
Array("A", "C", "H"), 0)) Then .EntireRow.Delete

End If

End With

Next Lrow

End With

ActiveWindow.View = ViewMode
With Application
.ScreenUpdating = True
.Calculation = CalcMode
End With

End Sub


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Determined07" wrote in message
...
I'm not exactly a new user, but this is the first time in a while that I've
had to apply this knowledge to my professional duties. The spreadsheet I'm
working on is considerably large and I need to retain rows that contain
certain text or specific criteria. For example, I only need items A, C, H,
and P, and Z out of a document that has everything else (i don't need) in
between. How do I delete based on specific criteria (letter, city name,)
withouth scrolling down and sifting through it manually? Please help me.





  #6   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 11,123
Default Filtering or deleting multiple rows

Hi

You can use SaveCopyAs to save the workbook with a new name and open that with
Workbooks.Open................................
See VBA help for more details

If you need more help post back

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Determined07" wrote in message ...
instead of editing the initial document and deleting from that particular
worksheet, would it be better (think in terms of a new user) to create a
whole new worksheet altogether, and pull the data that meets the criteria? If
that's recommended, please tell me how to do that. Thanks, you've been a
great help.

"Ron de Bruin" wrote:

Hi Determined07

Thanks for that. I need to delete the rows if a specific value does NOT

The macro do that

If IsError(Application.Match

If Not IsError(Application.Match ...........delete the items in the array

to retain, so it will be simpler to eliminate that bulk all at once


AutoFilter have a maximum of 2 criteria

Advanced filer is another option but you must add the values in a range
Start here
http://www.contextures.com/xladvfilter01.html


With my example above you can also fill in the values in a range
'Replace Array("A", "C", "H") with Sheets("Sheet1").Range("A1:A200")

There is also a Union example on my site that is faster if it is a large range


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Determined07" wrote in message
...
Thanks for that. I need to delete the rows if a specific value does NOT
exist. The amount of items that I need to delete is greater than those I need
to retain, so it will be simpler to eliminate that bulk all at once. How do I
do that? Please help me...there's this project going on and I've been so
frustrated.

Also, once it's deleted, I need to add a new column with text to
corresponding with the remaining text (that I retained) from the other column.

for example: F7 to F765 and j7 to j765 should be consistent with eachother.
I really feel at a loss.

"Ron de Bruin" wrote:

Start here
http://www.rondebruin.nl/delete.htm

For example try this one

This will check column A (Change it to the column you want)
'We check the values in the A column in this example
With .Cells(Lrow, "A")

Add the other values to the array in the macro

If IsError(Application.Match(.Value, _
Array("A", "C", "H"), 0)) Then .EntireRow.Delete

You can also add a list of values on another worksheet if you find that easy ?



Sub Loop_Example()
Dim Firstrow As Long
Dim Lastrow As Long
Dim Lrow As Long
Dim CalcMode As Long
Dim ViewMode As Long

With Application
CalcMode = .Calculation
.Calculation = xlCalculationManual
.ScreenUpdating = False
End With

'We use the ActiveSheet but you can replace this with
'Sheets("MySheet")if you want
With ActiveSheet

'We select the sheet so we can change the window view
.Select

'If you are in Page Break Preview Or Page Layout view go
'back to normal view, we do this for speed
ViewMode = ActiveWindow.View
ActiveWindow.View = xlNormalView

'Turn off Page Breaks, we do this for speed
.DisplayPageBreaks = False

'Set the first and last row to loop through
Firstrow = .UsedRange.Cells(1).Row
Lastrow = .UsedRange.Rows(.UsedRange.Rows.Count).Row

'We loop from Lastrow to Firstrow (bottom to top)
For Lrow = Lastrow To Firstrow Step -1

'We check the values in the A column in this example
With .Cells(Lrow, "A")

If Not IsError(.Value) Then

If IsError(Application.Match(.Value, _
Array("A", "C", "H"), 0)) Then .EntireRow.Delete

End If

End With

Next Lrow

End With

ActiveWindow.View = ViewMode
With Application
.ScreenUpdating = True
.Calculation = CalcMode
End With

End Sub


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Determined07" wrote in message
...
I'm not exactly a new user, but this is the first time in a while that I've
had to apply this knowledge to my professional duties. The spreadsheet I'm
working on is considerably large and I need to retain rows that contain
certain text or specific criteria. For example, I only need items A, C, H,
and P, and Z out of a document that has everything else (i don't need) in
between. How do I delete based on specific criteria (letter, city name,)
withouth scrolling down and sifting through it manually? Please help me.




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
Excel 2003; spreadsheet with filtering; deleting rows MHcoTech Excel Worksheet Functions 0 September 6th 06 01:33 AM
deleting vs. filtering . . . HELP! Wayne Knazek Excel Discussion (Misc queries) 9 July 26th 06 12:36 AM
Deleting a rows from multiple worksheets School Teacher Excel Worksheet Functions 0 July 6th 05 06:52 PM
Deleting multiple rows through a formula mike_vr Excel Discussion (Misc queries) 1 March 15th 05 01:29 PM
deleting multiple rows Pablo Excel Discussion (Misc queries) 4 January 27th 05 07:18 PM


All times are GMT +1. The time now is 05:37 PM.

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

About Us

"It's about Microsoft Excel"