LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
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/

 
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
How to delete a 'Select Box' Bodin Excel Discussion (Misc queries) 1 April 28th 09 01:53 AM
Cannot select checkbox to delete it from a spreadsheet Roundy Excel Discussion (Misc queries) 3 November 30th 05 02:38 PM
select and delete all blank rows Bill from UniqueAuction.com Excel Discussion (Misc queries) 1 October 11th 05 09:06 PM
Delete Select Targets Dathmar Excel Discussion (Misc queries) 1 August 24th 05 04:36 PM
Select All controls in a worksheet and delete them rova78 Excel Discussion (Misc queries) 1 April 28th 05 11:05 PM


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