LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 173
Default Delete Rows

Hi Norman,
Superb - That worked for me!!
Sorry took so long getting back to you, I had been away from the PC.
Many thanks for your help - much appreciated and thank you for your patience
Take care
Regards
John


"Norman Jones" wrote:

Hi John,

Try:

'================
Public Sub Tester()
Dim WB As Workbook
Dim SH As Worksheet
Dim rng As Range
Dim rCell As Range
Dim delRng As Range
Dim CalcMode As Long
Dim searchStr As String
Const SearchCol As String = "G" '<<===== CHANGE

Set WB =Workbooks("YourBook.xls") '<<===== CHANGE
Set SH = WB.Sheets("Sheet4") '<<===== CHANGE

searchStr = SH.Range("A1").Value '<<===== CHANGE


With SH
Set rng = Intersect(.Range("Names"), .Columns(SearchCol))
End With

If rng Is Nothing Then Exit Sub

On Error GoTo XIT
With Application
CalcMode = .Calculation
.Calculation = xlCalculationManual
.ScreenUpdating = False
End With

For Each rCell In rng.Cells
rCell.Select
If UCase(rCell.Value) = UCase(searchStr) Then
If delRng Is Nothing Then
Set delRng = rCell
Else
Set delRng = Union(rCell, delRng)
End If
End If
Next rCell

If Not delRng Is Nothing Then
'\\ ***SEE BELOW << ======
'Delete entire row
delRng.EntireRow.Delete

'Or, delete the contents of the entire row
' delRng.EntireRow.ClearContents


'Or, delete the intersection of the row with the "Names" range
' Intersect(delRng.EntireRow, SH.Range("Names")). _
Delete Shift:=xlUp

'Or, delete contents of the intersection of the row and "Names" range
' Intersect(delRng.EntireRow, SH.Range("Names")).ClearContents

End If

XIT:
With Application
.Calculation = CalcMode
.ScreenUpdating = True
End With

End Sub
'<<================

***
According to whether you wish to delete entire rows, delete part rows,
delete the contents of entire rows, or delete the contents of part rows,
choose the indicated code option and delete the remaining three. Note that
you will additionally need to delete the initial apostrophe for the selected
code line (not the preceding comment!).

If there are still problems, perhaps you could additionally indicate which
of these options corresponds with your requirements.


---
Regards,
Norman


"JohnUK" wrote in message
...
Sorry Norman it's me, not explaining very well.
If say I don't use a Range:
If I entered a name into Cell A1 (Any name) I then want all the rows that
have that name in column G Deleted.
I see you have worked very hard at the code and appreciate what you have
done and would fully understand if you gave up on me
John




 
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
Hpw do I delete multiple empty rows found between filled rows? Bill Excel Worksheet Functions 2 November 15th 09 07:12 PM
Cut filtered rows, paste into next empty row of new sheet, and delete cut rows Scott Excel Worksheet Functions 0 December 13th 06 01:25 AM
Delete rows with numeric values, leave rows with text GSpline Excel Programming 5 October 11th 05 12:44 AM
How to delete rows when List toolbar's "delete" isnt highlighted? Linda Excel Worksheet Functions 1 May 26th 05 08:39 PM
Delete every 3rd row, then delete rows 2-7, move info f/every 2nd row up one to the end and delete the row below Annette[_4_] Excel Programming 2 September 21st 04 02:40 PM


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