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 / July 2006

Tip: Looking for answers? Try searching our database.

Deleting entire row.... final question

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Pam Field - 22 Jul 2006 10:50 GMT
Thanks again to anyone who has helped me with this spreadsheet so far.  I'm
sure this will be my last question.

I have created a spreadsheet with a command button that leads to a form to
remove a child from the spreadsheet.  I have most of it working but cannot
work out how to delete the whole row of info re the child - my macro only
deletes the cell with the child's name in it and moves everything in that
column up.

Excuse the clumsiness of the code as I am a learner:

Private Sub cmdRemChild_Click()
   Dim myCell As Range
   Dim ChosenName As String
   Dim NameFound As Boolean
   Dim YesNo As Integer

   ChosenName = cboChildName.Text

   If Len(ChosenName) = 0 Then
       MsgBox ("Please Select or Enter A Name")
       cboChildName.SetFocus
       Exit Sub
   End If

   Sheets("Child Records").Select

   NameFound = False
   For Each myCell In Range("Name_of_Child")
       If myCell.Value = ChosenName Then
           myCell.Select
           NameFound = True
           YesNo = MsgBox("Are you sure you want to remove this child?",
vbYesNo + vbExclamation, "Caution")

           Select Case YesNo
           Case vbYes
               Selection.Delete Shift:=xlUp
               Range("A6").Select

           Case vbNo
               Range("A6").Select
           End Select
               Unload Me
       Exit For
       End If
   Next myCell

   If NameFound = False Then
       MsgBox "Name not Found!"
       cboChildName.SetFocus
       Exit Sub
   End If

End Sub

Your help would be greatly appreciated.
Kind Regards
Pam
Chris Lavender - 22 Jul 2006 12:11 GMT
Hi Pam

You need to replace

Selection.Delete Shift:=xlUp

with

Selection.EntireRow.Delete

Best rgds
Chris Lav

> Thanks again to anyone who has helped me with this spreadsheet so far.
> I'm sure this will be my last question.
[quoted text clipped - 55 lines]
> Kind Regards
> Pam
Pam Field - 22 Jul 2006 12:44 GMT
Thanks so much Chris,

I figured it wouldn't be too difficult but I just couldn't work it out.

Have a lovely weekend
Pam

> Hi Pam
>
[quoted text clipped - 8 lines]
> Best rgds
> Chris Lav
Don Guillett - 23 Jul 2006 13:29 GMT
a bit simpler

Sub deletechildrow()
Rows(Range("nameofchild").Find("a").Row).Delete
End Sub

Signature

Don Guillett
SalesAid Software
dguillett1@austin.rr.com

> Thanks again to anyone who has helped me with this spreadsheet so far.
> I'm sure this will be my last question.
[quoted text clipped - 55 lines]
> Kind Regards
> Pam
 
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.