Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #4  
Old 07-21-2020, 02:38 AM
gmayor's Avatar
gmayor gmayor is offline Radio buttons. Windows 10 Radio buttons. Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,144
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 ofgmayor has much to be proud of
Default

For this type of application, I would use content control list boxes rather than Active X radio buttons. It would then be relatively simple to collate the values, if that is what you wish, at the end. e.g. the following macro will list the various answers. Title the content controls "Answer 1", Answer 2" etc.
I would recommend using https://www.gmayor.com/insert_content_control_addin.htm to insert the first dropdown list control then copy and paste it as often as required, then use the same tool to edit the controls to change the names.



Code:
Sub Macro1()
Dim oCC As ContentControl
Dim i As Integer
Dim sYes As String, sNo As String, sNA As String
Dim collYes As Collection, CollNo As Collection, CollNA As Collection
    For Each oCC In ActiveDocument.ContentControls
        If oCC.ShowingPlaceholderText = True Then
            oCC.Range.Select
            MsgBox "Complete " & oCC.TITLE & "!"
            GoTo lbl_Exit
        End If
    Next oCC
    Set collYes = New Collection
    Set CollNo = New Collection
    Set CollNA = New Collection
    For Each oCC In ActiveDocument.ContentControls
        If oCC.Type = wdContentControlDropdownList And oCC.TITLE Like "Answer*" Then
            Select Case UCase(oCC.Range.Text)
                Case Is = "YES"
                    collYes.Add oCC.TITLE
                Case Is = "NO"
                    CollNo.Add oCC.TITLE
                Case Else
                    CollNA.Add oCC.TITLE
            End Select
        End If
    Next oCC
    For i = 1 To collYes.Count
        sYes = sYes & collYes.Item(i)
        If i < collYes.Count Then sYes = sYes & vbCr
    Next i
    For i = 1 To CollNo.Count
        sNo = sNo & CollNo.Item(i)
        If i < collYes.Count Then sNo = sNo & vbCr
    Next i
    For i = 1 To CollNA.Count
        sNA = sNA & CollNA.Item(i)
        If i < CollNA.Count Then sNA = sNA & vbCr
    Next i


    MsgBox "The following " & collYes.Count & " questions, were answered 'Yes'" & vbCr & sYes & vbCr & vbCr & _
           "The following " & CollNo.Count & " questions, were answered 'No'" & vbCr & sNo & vbCr & vbCr & _
           "The following " & CollNA.Count & " questions, were answered 'N/A'" & vbCr & sNA
lbl_Exit:
    Set collYes = Nothing
    Set CollNo = Nothing
    Set CollNA = Nothing
    Set oCC = Nothing
    Exit Sub
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
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Need help with userform and radio buttons Fissure Word VBA 4 04-27-2018 04:10 AM
Radio Buttons in Word Document in MAC Office 2016 kim88 Word 3 12-19-2016 03:36 PM
check box issue (problem with radio buttons from web page) Word 2013 cQQlgirl Word 6 03-19-2015 07:23 PM
Radio buttons. Performance problem ActiveX radio buttons NobodysPerfect Word VBA 8 05-31-2014 03:51 AM
example of radio buttons in for data entry? derohanes Excel 1 03-05-2011 09:37 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 03:57 PM.


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