Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / New Users / January 2007

Tip: Looking for answers? Try searching our database.

Delete Row

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Bernie - 25 Jan 2007 16:43 GMT
In Excel, I need a macro that will delete an entire row based on a name
entered into an input box that would match a worksheet with that name
in column "A".

Thanks,
Bernie
Mike - 25 Jan 2007 17:54 GMT
I hope i've understood your question. The macro below looks in the sheet
entered into the input box to get the sheet name you want to delete a row in
and finds that name in A1. It then deletes row 13 in the sheet with the name
it finds in that cell.

Sub deleterow()
msg = "Which sheet has the name of the sheet you want to delete a row in"
sname = InputBox(msg)
If sname = "" Then
       End
Else
       sheettodeletein = Worksheets(sname).Cells(1, 1).Value
End If

   Worksheets(sheettodeletein).Cells(13, 1).Select
   Selection.Rows.EntireRow.Delete
   
   
End Sub

> In Excel, I need a macro that will delete an entire row based on a name
> entered into an input box that would match a worksheet with that name
> in column "A".
>
> Thanks,
> Bernie
Bernie - 25 Jan 2007 18:46 GMT
It's close.

The name I input is the name of a person in the speadsheet whose row I
need to delete.  I will have the sheet selected before the macro runs.

Hope that is more clear.

Thanks,
Bern

> I hope i've understood your question. The macro below looks in the sheet
> entered into the input box to get the sheet name you want to delete a row in
[quoted text clipped - 21 lines]
> > Thanks,
> > Bernie- Hide quoted text -- Show quoted text -
JLatham - 28 Jan 2007 17:52 GMT
Then perhaps this will assist:
Sub MatchAndDelete()
   Dim WhoToFind As String
   Dim anyRange As Range
   Dim startRange As String
   
   startRange = Selection.Address
   WhoToFind = InputBox$("Enter Name to find", "Name", "")
   If WhoToFind = "" Then
       Exit Sub ' no entry given
   End If
   Set anyRange = Range("A:A") ' change as required
   anyRange.Select
   On Error Resume Next ' in case of no match
   Selection.Find(What:=WhoToFind, After:=ActiveCell, _
     LookIn:=xlValues, LookAt:=xlPart, SearchOrder:=xlByRows, _
     SearchDirection:=xlNext, _
     MatchCase:=False, SearchFormat:=False).Select
   If Err <> 0 Then
       Err.Clear
       On Error GoTo 0
       Range(startRange).Select ' back to where we were
       MsgBox "No match for the entered name found"
       Exit Sub
   End If
   On Error GoTo 0
   Selection.EntireRow.Delete
End Sub

> It's close.
>
[quoted text clipped - 31 lines]
> > > Thanks,
> > > Bernie- Hide quoted text -- Show quoted text -
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.