How to remove the caption from string variable

Pookiemeister

Well-known Member
Joined
Jan 6, 2012
Messages
563
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
On my user-form, I have three checkboxes and public string variable called Description. For test purposes, I am using a message box to display the outcome. What I am wanting to do, if the user selects a checkbox it displays the caption of the checkbox in the message box. As another checkbox gets checked, it adds it to the variable. If the user deselects a checkbox, how can I remove it from the variable string? If there are any questions, comments, or concerns, please let me know. Thank you.

VBA Code:
Private Sub chkbxCIMN_Click()
   
    If chkbxCIMN.Value = True Then
        Description = Description & UCase(chkbxCIMN.Caption) & ", "
        MsgBox Description
    Else
        If Description = UCase(chkbxCIMN.Caption) Then
            Description = Description & ""
            MsgBox Description
        End If
       
    End If

End Sub
VBA Code:
Private Sub chkbxKP_Click()
    If chkbxKP.Value = True Then
        Description = Description & UCase(chkbxKP.Caption) & ", "
        MsgBox Description
    Else
        MsgBox Description
    End If
    
End Sub

VBA Code:
Private Sub chkbxTroubleshoot_Click()
    If chkbxTroubleshoot.Value = True Then
        Description = Description & UCase(chkbxTroubleshoot.Caption) & ", "
        MsgBox Description
    Else
        MsgBox Description
    End If
End Sub
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
How about
VBA Code:
Private Sub chkbxCIMN_Click()
   
    If chkbxCIMN.Value = True Then
        Description = Description & UCase(chkbxCIMN.Caption) & ", "
    Else
        Description = Replace(Description, chkbxCIMN.Caption & ", ", "", , , vbTextCompare)
    End If
    MsgBox Description

End Sub
 
Upvote 0

Forum statistics

Threads
1,213,536
Messages
6,114,215
Members
448,554
Latest member
Gleisner2

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top