View Single Post
 
Old 02-22-2015, 11:27 PM
gmayor's Avatar
gmayor gmayor is offline Windows 7 64bit Office 2010 32bit
Expert
 
Join Date: Aug 2014
Posts: 4,106
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

The problem is that you are counting controls to determine which column to fill. The macro has no way of knowing that you have removed a control so it works on the basis that the new count is correct. You need to address the controls by name and fill the column related to that control name e.g.

Code:
        For Each CCtrl In .ContentControls
            Select Case CCtrl.Title
                Case "Title1": WkSht.Cells(i, 1) = CCtrl.Range.Text
                Case "Title2": WkSht.Cells(i, 2) = CCtrl.Range.Text
                    'etc
            End Select
        Next oCC
This will mean that you will have to add names to the CCs before they are filled by your users.
__________________
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