View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
jagstirling[_5_] jagstirling[_5_] is offline
external usenet poster
 
Posts: 1
Default Conditional Row Select and Delete

I am trying to write a Macro that will select Certain rows within a
worksheet and, depending on the character in the cell of column A,
delete or skip each selected row.

The Start cell needs to be A6, moving slowly down row by row (for
atleast 3,000 rows).

The 5 characters I have that I want to detect in Column A and then
delete their rows are ..............

Character1 = "Tel"
Character2 = "" (THIS IS A BLANK CELL IE. NO ENTRY MADE)
Character3 = "Catg"
Character4 = "-----"
Character5 = " "

I have had a stab (see below). I am getting stuck when it comes to rows
that are NOT equal to those Characters above.

*CAN ANYONE HELP ?*

Regards and thanks, J. :)





Dim X As Integer
Dim Y As Integer
Dim Character1 As Integer
Dim Character2 As Integer
Dim Character3 As Integer
Dim Character4 As Integer
Dim Character5 As Integer

Character1 = "Tel"
Character2 = ""
Character3 = "Catg"
Character4 = "-----"
Character5 = " "

For X = 2 To Application.WorksheetFunction.CountA(Sheets(1).Col umns(1))
- 1

If Sheets(1).Cells(X, 1).Value = Character1 Then
Rows(X).Delete

If Sheets(1).Cells(X, 1).Value = Character2 Then
Rows(X).Delete

If Sheets(1).Cells(X, 1).Value = Character3 Then
Rows(X).Delete

If Sheets(1).Cells(X, 1).Value = Character4 Then
Rows(X).Delete

If Sheets(1).Cells(X, 1).Value = Character5 Then
Rows(X).Delete

If Sheets(1).Cells(X, 1).Value < Character1 Then
Rows(X).Offset (1,0)

If Sheets(1).Cells(X, 1).Value < Character2 Then
Rows(X).Offset (1,0)

If Sheets(1).Cells(X, 1).Value < Character3 Then
Rows(X).Offset (1,0)

If Sheets(1).Cells(X, 1).Value < Character4 Then
Rows(X).Offset (1,0)

If Sheets(1).Cells(X, 1).Value < Character5 Then
Rows(X).Offset (1,0)



End Sub



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/