#1   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 20
Default Delete Row

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

  #2   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 3,101
Default Delete Row

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


"Bernie" wrote:

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


  #3   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 20
Default Delete Row

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

On Jan 25, 12:54 pm, Mike wrote:
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



"Bernie" wrote:
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- Hide quoted text -- Show quoted text -


  #4   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 3,365
Default Delete Row

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


"Bernie" wrote:

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

On Jan 25, 12:54 pm, Mike wrote:
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



"Bernie" wrote:
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- Hide quoted text -- Show quoted text -



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
I can't delete an image in excel workbook [email protected] Excel Discussion (Misc queries) 6 October 13th 06 06:41 PM
Delete cell on 1 page: automatically delete on another page? mountain view Excel Worksheet Functions 0 September 28th 06 04:18 PM
I can't delete a cell without deleting a row Tenny Excel Discussion (Misc queries) 2 June 30th 06 12:52 AM
how do I delete a worksheet from my workbook DLee New Users to Excel 2 August 15th 05 09:59 PM
Delete row depending on criteria adw223 Excel Discussion (Misc queries) 1 June 30th 05 12:55 AM


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

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"