Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Cell Value to String and Trim then Delete un-needed Rows

'Basically I need to sort through all of the rows on a worksheet.
'If the cell value in Column "I" equals the cell value in Cell "B2",
then
'I keep the ROW, ELSE DELETE the ROW. Here is what I have so far.
'One NOTE: The Data in Cell C2 has Extra spaces that need to be
Trimmed off First.
'I use this to sort through Multiple worksheets changing from Cell
Value C2 to C3, C4 etc.

Dim SAVESTR As String

If Sheets("RCM").Range("C2") = "" Then
Else
SAVESTR = Sheets("RCM").Range("C2").Value
End If
Sheets("Hardware (2)").Activate
Columns("I:I").Select
On Error Resume Next
Selection.Find(What:=SAVESTR, After:=ActiveCell,
LookIn:=xlFormulas, LookAt _
:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:= _
False).Activate
If Err.Number < 91 And Err.Number < 0 Then
MsgBox "Unresolved Error"
Exit Sub
End If
If ActiveCell.Row 1 Then
Set myRange = Range("I1").Resize(Range( _
"I" & Rows.Count).End(xlUp).Row, 1)
For Each cell In myRange
If cell.Value < SAVESTR Then
If delRange Is Nothing Then
Set delRange = cell
Else
Set delRange = Union(delRange, cell)
End If
End If
Next cell
If Not delRange Is Nothing Then delRange.EntireRow.Delete
Range("B1").Select
Selection.EntireRow.Insert
Else
Columns("A:A").ColumnWidth = 2
End If
Application.ScreenUpdating = False
End Sub


'Any And all suggestions will be appreciated.

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
Marco to delete all rows except those containing 'MZ' in string [email protected] Excel Programming 6 April 3rd 07 06:46 PM
DELETE ROWS FROM XLS IF THE ROW CONTAINS THE STRING [email protected] Excel Discussion (Misc queries) 1 September 30th 06 01:21 PM
Macro needed to delete rows simmerdown Excel Programming 4 March 27th 06 04:00 PM
putting a string from one cell in the formula of another -- indirect needed? [email protected] Excel Worksheet Functions 3 January 23rd 06 07:55 PM
Trim string vII Jesse Hamilton[_2_] Excel Programming 2 November 10th 03 08:43 PM


All times are GMT +1. The time now is 04:03 PM.

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"