Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 84
Default Only keep rows that contain

I posted this question once, but didn't phrase it properly; let me try
again. I want to delete all rows that do not contain the text of T75TA in
column A. There are over 10,000 rows of data so this macro would really help
me out. Thank you.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Only keep rows that contain

See this page
http://www.rondebruin.nl/delete.htm

For so many rows try the Filter or union example


--

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


"SITCFanTN" wrote in message ...
I posted this question once, but didn't phrase it properly; let me try
again. I want to delete all rows that do not contain the text of T75TA in
column A. There are over 10,000 rows of data so this macro would really help
me out. Thank you.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,565
Default Only keep rows that contain

I believe somebody posted code similar to the code below for you in the
other posting.

Sub delIfnot()
Dim sh As Worksheet, lr As Long
Set sh = ActiveSheet
lr = sh.Cells(Rows.Count, 1).End(xlUp).Row
For i = lr To 2 Step -1
If InStr(Range("A" & i).Value,T75TA) = < 1 Then
Rows(i).Delete
End If
Next
End Sub

Try it and see if it does the job.



"SITCFanTN" wrote in message
...
I posted this question once, but didn't phrase it properly; let me try
again. I want to delete all rows that do not contain the text of T75TA in
column A. There are over 10,000 rows of data so this macro would really
help
me out. Thank you.



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,565
Default Only keep rows that contain

Search string needed to be in quotes.

Sub delIfnot()
Dim sh As Worksheet, lr As Long
Set sh = ActiveSheet
lr = sh.Cells(Rows.Count, 1).End(xlUp).Row
For i = lr To 2 Step -1
If InStr(Range("A" & i).Value, "T75TA") = < 1 Then
Rows(i).Delete
End If
Next
End Sub



"SITCFanTN" wrote in message
...
I posted this question once, but didn't phrase it properly; let me try
again. I want to delete all rows that do not contain the text of T75TA in
column A. There are over 10,000 rows of data so this macro would really
help
me out. Thank you.



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default Only keep rows that contain

JLGWhiz - I modified this code and it works for me.
If InStr(Range("A" & i).Value, "T75TA") = 0

Sub delIfnot()
Dim sh As Worksheet, lr As Long
Set sh = ActiveSheet
lr = sh.Cells(Rows.Count, 1).End(xlUp).Row
For i = lr To 2 Step -1
If InStr(Range("A" & i).Value, "T75TA") = 0 Then
Rows(i).Delete
End If
Next
End Sub

I also was working an alternate solution and here is that macro:

Sub OnlyKeepT75A()
On Error Resume Next
lastrow = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).Row
For A = lastrow To 2 Step -1
If IsError(WorksheetFunction.Find("T75TA", Cells(A, 1).Value, 1)) Then
Cells(A, 1).EntireRow.Delete
End If
Next
End Sub


HTH
--
Data Hog


"JLGWhiz" wrote:

Search string needed to be in quotes.

Sub delIfnot()
Dim sh As Worksheet, lr As Long
Set sh = ActiveSheet
lr = sh.Cells(Rows.Count, 1).End(xlUp).Row
For i = lr To 2 Step -1
If InStr(Range("A" & i).Value, "T75TA") = < 1 Then
Rows(i).Delete
End If
Next
End Sub



"SITCFanTN" wrote in message
...
I posted this question once, but didn't phrase it properly; let me try
again. I want to delete all rows that do not contain the text of T75TA in
column A. There are over 10,000 rows of data so this macro would really
help
me out. Thank you.



.



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,565
Default Only keep rows that contain

The OP wanted to delete the row if T75TA was not found in col A. Filtering
would have worked just as well, but sometimes the person posting has other
things in mind.


"J_Knowles" wrote in message
...
JLGWhiz - I modified this code and it works for me.
If InStr(Range("A" & i).Value, "T75TA") = 0

Sub delIfnot()
Dim sh As Worksheet, lr As Long
Set sh = ActiveSheet
lr = sh.Cells(Rows.Count, 1).End(xlUp).Row
For i = lr To 2 Step -1
If InStr(Range("A" & i).Value, "T75TA") = 0 Then
Rows(i).Delete
End If
Next
End Sub

I also was working an alternate solution and here is that macro:

Sub OnlyKeepT75A()
On Error Resume Next
lastrow = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).Row
For A = lastrow To 2 Step -1
If IsError(WorksheetFunction.Find("T75TA", Cells(A, 1).Value, 1)) Then
Cells(A, 1).EntireRow.Delete
End If
Next
End Sub


HTH
--
Data Hog


"JLGWhiz" wrote:

Search string needed to be in quotes.

Sub delIfnot()
Dim sh As Worksheet, lr As Long
Set sh = ActiveSheet
lr = sh.Cells(Rows.Count, 1).End(xlUp).Row
For i = lr To 2 Step -1
If InStr(Range("A" & i).Value, "T75TA") = < 1 Then
Rows(i).Delete
End If
Next
End Sub



"SITCFanTN" wrote in message
...
I posted this question once, but didn't phrase it properly; let me try
again. I want to delete all rows that do not contain the text of T75TA
in
column A. There are over 10,000 rows of data so this macro would
really
help
me out. Thank you.



.



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 84
Default Only keep rows that contain

This worked great, thank you so much...the 0 was the key! Happy Holidays

"J_Knowles" wrote:

JLGWhiz - I modified this code and it works for me.
If InStr(Range("A" & i).Value, "T75TA") = 0

Sub delIfnot()
Dim sh As Worksheet, lr As Long
Set sh = ActiveSheet
lr = sh.Cells(Rows.Count, 1).End(xlUp).Row
For i = lr To 2 Step -1
If InStr(Range("A" & i).Value, "T75TA") = 0 Then
Rows(i).Delete
End If
Next
End Sub

I also was working an alternate solution and here is that macro:

Sub OnlyKeepT75A()
On Error Resume Next
lastrow = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).Row
For A = lastrow To 2 Step -1
If IsError(WorksheetFunction.Find("T75TA", Cells(A, 1).Value, 1)) Then
Cells(A, 1).EntireRow.Delete
End If
Next
End Sub


HTH
--
Data Hog


"JLGWhiz" wrote:

Search string needed to be in quotes.

Sub delIfnot()
Dim sh As Worksheet, lr As Long
Set sh = ActiveSheet
lr = sh.Cells(Rows.Count, 1).End(xlUp).Row
For i = lr To 2 Step -1
If InStr(Range("A" & i).Value, "T75TA") = < 1 Then
Rows(i).Delete
End If
Next
End Sub



"SITCFanTN" wrote in message
...
I posted this question once, but didn't phrase it properly; let me try
again. I want to delete all rows that do not contain the text of T75TA in
column A. There are over 10,000 rows of data so this macro would really
help
me out. Thank you.



.

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default Only keep rows that contain

Your welcome, I am curious if you tried the alternate macro to see which one
was the fastest. I'm thinking the Instr command will be faster than the
WorksheetFunction.Find. Let me know which one is the best.
--
Data Hog


"SITCFanTN" wrote:

This worked great, thank you so much...the 0 was the key! Happy Holidays

"J_Knowles" wrote:

JLGWhiz - I modified this code and it works for me.
If InStr(Range("A" & i).Value, "T75TA") = 0


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
colating multi rows of data into single rows - no to pivot tables! UKMAN Excel Worksheet Functions 4 March 12th 10 04:11 PM
Enabling option „Format rows“ to hide/unhide rows using VBA-code? ran58 Excel Discussion (Misc queries) 0 July 28th 09 03:46 PM
Counting characters in multiple rows when rows meet specific criteria news.virginmedia.com Excel Worksheet Functions 3 June 28th 08 09:03 PM
"Add/Remove Rows Code" adds rows on grouped sheets, but won't remove rows. Conan Kelly Excel Programming 1 November 16th 07 10:41 PM
Pivot Tables: How do I show ALL field rows, including empty rows?? [email protected] Excel Worksheet Functions 2 April 8th 05 06:21 PM


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