Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 59
Default Delete rows based on text value in a range

I have a file that I update weekly and the data source has been
changed to include more data than what I need. I cannot sort
the data from the source so I am trying to create a macro in
excel to remove the extra data I do not need. I only need 14
rows of data, but my source now gives me 55.

I have looked at Ron DeBruin's site for assistance:

http://www.rondebruin.nl/delete.htm#Find

But since I need to remove 41 rows of unneeded data, I was
unsure how to adapt it to my needs. I want to be able to
remove rows based on the text value in column A.

Does anyone have any advice?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Delete rows based on text value in a range

Hi,

Right click your sheet tab, view code and paste this in. Change the text
(Cirrectly TEST) to the text you want but it must be in uppercase.

Sub marine()
Dim myrange As Range, MyRange1 As Range
lastrow = Cells(Rows.Count, "A").End(xlUp).Row
Set myrange = Range("A1:A" & lastrow)
For Each c In myrange
If UCase(Trim(c.Value)) = "TEST" Then 'Change to suit must be upercase
If MyRange1 Is Nothing Then
Set MyRange1 = c.EntireRow
Else
Set MyRange1 = Union(MyRange1, c.EntireRow)
End If
End If
Next
If Not MyRange1 Is Nothing Then MyRange1.Delete
End Sub


"Opal" wrote:

I have a file that I update weekly and the data source has been
changed to include more data than what I need. I cannot sort
the data from the source so I am trying to create a macro in
excel to remove the extra data I do not need. I only need 14
rows of data, but my source now gives me 55.

I have looked at Ron DeBruin's site for assistance:

http://www.rondebruin.nl/delete.htm#Find

But since I need to remove 41 rows of unneeded data, I was
unsure how to adapt it to my needs. I want to be able to
remove rows based on the text value in column A.

Does anyone have any advice?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Delete rows based on text value in a range

The example is working for column A on my page

What are the values that you want to delete in Column A ?

--

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


"Opal" wrote in message ...
I have a file that I update weekly and the data source has been
changed to include more data than what I need. I cannot sort
the data from the source so I am trying to create a macro in
excel to remove the extra data I do not need. I only need 14
rows of data, but my source now gives me 55.

I have looked at Ron DeBruin's site for assistance:

http://www.rondebruin.nl/delete.htm#Find

But since I need to remove 41 rows of unneeded data, I was
unsure how to adapt it to my needs. I want to be able to
remove rows based on the text value in column A.

Does anyone have any advice?

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 59
Default Delete rows based on text value in a range

On Sep 15, 1:32*pm, "Ron de Bruin" wrote:
The example is working for column A on my page

What are the values that you want to delete in Column A ?

--

Regards Ron de Bruinhttp://www.rondebruin.nl/tips.htm



"Opal" wrote in ...
I have a file that I update weekly and the data source has been
changed to include more data than what I need. *I cannot sort
the data from the source so I am trying to create a macro in
excel to remove the extra data I do not need. *I only need 14
rows of data, but my source now gives me 55.


I have looked at Ron DeBruin's site for assistance:


http://www.rondebruin.nl/delete.htm#Find


But since I need to remove 41 rows of unneeded data, I was
unsure how to adapt it to my needs. *I want to be able to
remove rows based on the text value in column A.


Does anyone have any advice?- Hide quoted text -


- Show quoted text -


Hi Ron,

I used your code from your site and typed in all 41 values I want to
delete in this line:

myStrings = Array("Ron", "Dave", "Tom")


it works, but I wondered if there was a more effective way to achieve
my results.
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Delete rows based on text value in a range

You can also use a range with the words
Easier to change then

See this tip for the first macro on this page
http://www.rondebruin.nl/delete.htm

If Not IsError(Application.Match(.Value, _
Array("jelle", "ron", "dave"), 0)) Then .EntireRow.Delete
'Or use this one with Application.Match if you want to check more values.
'in the cell. You can also use a range with the values to delete.
'Replace Array("jelle", "ron", "dave") with Sheets("Sheet1").Range("A1:A200")



--

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


"Opal" wrote in message ...
On Sep 15, 1:32 pm, "Ron de Bruin" wrote:
The example is working for column A on my page

What are the values that you want to delete in Column A ?

--

Regards Ron de Bruinhttp://www.rondebruin.nl/tips.htm



"Opal" wrote in ...
I have a file that I update weekly and the data source has been
changed to include more data than what I need. I cannot sort
the data from the source so I am trying to create a macro in
excel to remove the extra data I do not need. I only need 14
rows of data, but my source now gives me 55.


I have looked at Ron DeBruin's site for assistance:


http://www.rondebruin.nl/delete.htm#Find


But since I need to remove 41 rows of unneeded data, I was
unsure how to adapt it to my needs. I want to be able to
remove rows based on the text value in column A.


Does anyone have any advice?- Hide quoted text -


- Show quoted text -


Hi Ron,

I used your code from your site and typed in all 41 values I want to
delete in this line:

myStrings = Array("Ron", "Dave", "Tom")


it works, but I wondered if there was a more effective way to achieve
my results.


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 59
Default Delete rows based on text value in a range

On Sep 17, 11:34*am, "Ron de Bruin" wrote:
You can also use a range with the words
Easier to change then

See this tip for the first macro on this pagehttp://www.rondebruin.nl/delete.htm

If Not IsError(Application.Match(.Value, _
Array("jelle", "ron", "dave"), 0)) Then .EntireRow.Delete
'Or use this one with Application.Match if you want to check more values.
'in the cell. You can also use a range with the values to delete.
'Replace Array("jelle", "ron", "dave") *with *Sheets("Sheet1").Range("A1:A200")

--

Regards Ron de Bruinhttp://www.rondebruin.nl/tips.htm

"Opal" wrote in ...

On Sep 15, 1:32 pm, "Ron de Bruin" wrote:





The example is working for column A on my page


What are the values that you want to delete in Column A ?


--


Regards Ron de Bruinhttp://www.rondebruin.nl/tips.htm


"Opal" wrote in ...
I have a file that I update weekly and the data source has been
changed to include more data than what I need. I cannot sort
the data from the source so I am trying to create a macro in
excel to remove the extra data I do not need. I only need 14
rows of data, but my source now gives me 55.


I have looked at Ron DeBruin's site for assistance:


http://www.rondebruin.nl/delete.htm#Find


But since I need to remove 41 rows of unneeded data, I was
unsure how to adapt it to my needs. I want to be able to
remove rows based on the text value in column A.


Does anyone have any advice?- Hide quoted text -


- Show quoted text -


Hi Ron,

I used your code from your site and typed in all 41 values I want to
delete in this line:

*myStrings = Array("Ron", "Dave", "Tom")

it works, but I wondered if there was a more effective way to achieve
my results.- Hide quoted text -

- Show quoted text -


Ron,

I tried replacing

myStrings = Array(.....

With

myStrings = Sheets("DataReq").Range("A1:A39")

and got an error "Subscript out of range"

Did I miss something?
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Delete rows based on text value in a range

See the first macro example on the page
Below the macro you can read how you can add the range option


--

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


"Opal" wrote in message ...
On Sep 17, 11:34 am, "Ron de Bruin" wrote:
You can also use a range with the words
Easier to change then

See this tip for the first macro on this pagehttp://www.rondebruin.nl/delete.htm

If Not IsError(Application.Match(.Value, _
Array("jelle", "ron", "dave"), 0)) Then .EntireRow.Delete
'Or use this one with Application.Match if you want to check more values.
'in the cell. You can also use a range with the values to delete.
'Replace Array("jelle", "ron", "dave") with Sheets("Sheet1").Range("A1:A200")

--

Regards Ron de Bruinhttp://www.rondebruin.nl/tips.htm

"Opal" wrote in ...

On Sep 15, 1:32 pm, "Ron de Bruin" wrote:





The example is working for column A on my page


What are the values that you want to delete in Column A ?


--


Regards Ron de Bruinhttp://www.rondebruin.nl/tips.htm


"Opal" wrote in ...
I have a file that I update weekly and the data source has been
changed to include more data than what I need. I cannot sort
the data from the source so I am trying to create a macro in
excel to remove the extra data I do not need. I only need 14
rows of data, but my source now gives me 55.


I have looked at Ron DeBruin's site for assistance:


http://www.rondebruin.nl/delete.htm#Find


But since I need to remove 41 rows of unneeded data, I was
unsure how to adapt it to my needs. I want to be able to
remove rows based on the text value in column A.


Does anyone have any advice?- Hide quoted text -


- Show quoted text -


Hi Ron,

I used your code from your site and typed in all 41 values I want to
delete in this line:

myStrings = Array("Ron", "Dave", "Tom")

it works, but I wondered if there was a more effective way to achieve
my results.- Hide quoted text -

- Show quoted text -


Ron,

I tried replacing

myStrings = Array(.....

With

myStrings = Sheets("DataReq").Range("A1:A39")

and got an error "Subscript out of range"

Did I miss something?
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 rows based upon a range of times farmboy Excel Discussion (Misc queries) 6 October 16th 09 05:02 PM
Delete Rows based on value Sabosis Excel Worksheet Functions 4 October 28th 08 11:21 PM
find & delete rows based on text deb Excel Discussion (Misc queries) 4 September 17th 08 01:02 AM
Delete Rows based on not existing in range [email protected] Excel Programming 3 June 29th 07 02:16 PM
Delete rows based on value... Gordon[_2_] Excel Programming 3 September 15th 06 09:14 PM


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