ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   URGENT! Find and delete row macro (https://www.excelbanter.com/excel-programming/297240-urgent-find-delete-row-macro.html)

newmand2[_3_]

URGENT! Find and delete row macro
 
Hi all, I posted a thread similar to this a few days ago but it did no
yield the perfect results :(

After a long search on google, I came across some code on the M
website, and I modified it to my needs.

This is my code as it stands now:


Code
-------------------


Sub DelCustomer()

Sheets("Database").Select
testValue = InputBox("Enter the customer's user ID to delete")
For Each x In ActiveWindow.SelectedSheets
x.Select
Set foundcell = ActiveSheet.Cells.Find(testValue)
If foundcell Is Nothing Then
MsgBox "The customer was not found"
Else
MsgBox "The customer was found"
Range(foundcell.Address).Select

LookAgain:
response = MsgBox _
("Delete this customer?", vbYesNo)

' If response = 6, we will not continue searching on
' this sheet.
If response = 6 Then

' Part2
Set foundcell = _
Range(foundcell.Address).Select
Selection.Delete Shift:=xlUp

End If

If response = 7 Then
response = MsgBox("Cancel search ? ", vbYesNo)
If response = 6 Then End
GoTo NextSheet
End If
End If

NextSheet:
Next x
MsgBox "Search is complete ....."

End Sub



-------------------


Currently, the search works and it selects the cell correctly. However
when I tried to add my own line of code to delete the row, I was no
successful. What I am asking for help on is to select the cell, the
use that to select the row. Then delete that row.

I am very pressed for time (like 3 hours or so) so this is greatl
appreciated. Thanks!!

--
Message posted from http://www.ExcelForum.com


pikus

URGENT! Find and delete row macro
 
Selection.Delete Shift:=xlUp

should be

Selection.EntireRow.Delete

- Piku

--
Message posted from http://www.ExcelForum.com


newmand2[_4_]

URGENT! Find and delete row macro
 
YES! thank you! works amazingly! hurrah! you have all my praise! than
you so much

--
Message posted from http://www.ExcelForum.com



All times are GMT +1. The time now is 09:28 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com