Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 10
Default Macro to delete rows containing specific data

I have a spreadsheet with the following data in a column:

C100
C101
MTH1
MTH2
R1
R2
TP1
TP2

I wish to delete all rows that contain MTH or TP in that column.
A macro to do this would be great.
--
Thanks
Slohcin
  #2   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 11,058
Default Macro to delete rows containing specific data

Sub demo()
s1 = "MTH"
s2 = "TP"
For i = 1000 To 1 Step -1
v = Cells(i, "A").Value
If InStr(v, s1) Or InStr(v, s2) Then
Cells(i, "A").EntireRow.Delete
End If
Next
End Sub

This is coded for column A and 1000 rows, adjust as you require.
--
Gary's Student


"Slohcin" wrote:

I have a spreadsheet with the following data in a column:

C100
C101
MTH1
MTH2
R1
R2
TP1
TP2

I wish to delete all rows that contain MTH or TP in that column.
A macro to do this would be great.
--
Thanks
Slohcin

  #3   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 10
Default Macro to delete rows containing specific data

Thanks Gary, that worked OK.
--
Thanks
Slohcin


"Gary''s Student" wrote:

Sub demo()
s1 = "MTH"
s2 = "TP"
For i = 1000 To 1 Step -1
v = Cells(i, "A").Value
If InStr(v, s1) Or InStr(v, s2) Then
Cells(i, "A").EntireRow.Delete
End If
Next
End Sub

This is coded for column A and 1000 rows, adjust as you require.
--
Gary's Student


"Slohcin" wrote:

I have a spreadsheet with the following data in a column:

C100
C101
MTH1
MTH2
R1
R2
TP1
TP2

I wish to delete all rows that contain MTH or TP in that column.
A macro to do this would be great.
--
Thanks
Slohcin

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
unable to filter by specific data on a column if the rows exceed 1 Devarajan Mohan Excel Worksheet Functions 0 December 6th 06 01:47 AM
macro unouwanme Excel Discussion (Misc queries) 9 August 31st 06 09:38 PM
Excel Macro to Copy & Paste [email protected] Excel Worksheet Functions 0 December 1st 05 01:56 PM
Delete rows with no data Mindie Setting up and Configuration of Excel 1 November 30th 05 09:24 PM
Extract specific data into its own workbook via macro? Adrian B Excel Discussion (Misc queries) 2 February 24th 05 06:09 AM


All times are GMT +1. The time now is 02:53 AM.

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"