Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 12-06-2017, 07:28 PM
baes10 baes10 is offline Could you help me create a control button/check box to enable user to delete a row? Windows 7 64bit Could you help me create a control button/check box to enable user to delete a row? Office 2007
Advanced Beginner
Could you help me create a control button/check box to enable user to delete a row?
 
Join Date: Dec 2017
Posts: 33
baes10 is on a distinguished road
Default Could you help me create a control button/check box to enable user to delete a row?


I have here a skin form i use to track wounds. I have now a macro to create a new row when needed. I need help creating a check box or a button next two each row to enable deletion of the entire row. Could you help? Thanks!
Attached Files
File Type: docm Skin Report.docm (88.2 KB, 32 views)
Reply With Quote
  #2  
Old 12-11-2017, 01:26 AM
gmayor's Avatar
gmayor gmayor is offline Could you help me create a control button/check box to enable user to delete a row? Windows 10 Could you help me create a control button/check box to enable user to delete a row? Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,101
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

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
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
  #3  
Old 12-11-2017, 10:10 AM
baes10 baes10 is offline Could you help me create a control button/check box to enable user to delete a row? Windows 7 64bit Could you help me create a control button/check box to enable user to delete a row? Office 2007
Advanced Beginner
Could you help me create a control button/check box to enable user to delete a row?
 
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
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to get control/option-delete to only delete the word and not the preceding space microsofthelp Word 0 11-20-2016 04:34 AM
Could you help me create a control button/check box to enable user to delete a row? Force a user to enable macros in Powerpoint? Hide sheets until the "enable" button is clicked copleyr PowerPoint 1 10-07-2016 01:15 AM
Could you help me create a control button/check box to enable user to delete a row? Enable "check spelling as you type" for Form Fields zeroth Word 3 11-08-2012 08:57 AM
Could you help me create a control button/check box to enable user to delete a row? How do I enable a button in the quick access toolbar dpb001 Word VBA 1 05-02-2012 12:41 AM
issue in nested user control selva Misc 1 10-20-2011 10:18 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 09:21 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft