View Single Post
 
Old 12-11-2017, 10:10 AM
baes10 baes10 is offline Windows 7 64bit Office 2007
Advanced Beginner
 
Join Date: Dec 2017
Posts: 33
baes10 is on a distinguished road
Default

Quote:
Originally Posted by gmayor View Post
As your form already contains code to add a row, then delete all the rows except the first to begin with and only add the rows as you require them, however to address your question the following will delete the row the cursor is in.

Code:
Sub DeleteTableRow()
Dim oCC As ContentControl
    If Selection.Information(wdWithInTable) = True Then
        For Each oCC In Selection.Rows(1).Range.ContentControls
            oCC.LockContentControl = False
            oCC.Delete
        Next oCC
        Selection.Rows(1).Delete
    Else
        MsgBox "Selection is not in a table!"
    End If
End Sub
This is fantastic! May I ask one more question? I'd like to create a userform command button, to enable users to click and delete the rows as they wish in a protected form. None of the users will have a developer tool option. Basically, I need to make it as easy for the nurses to use as possible. Having the cursor in the row and being able to click the comman button to delete would be great. Hope this makes sense. Thank you!
Reply With Quote