+ Reply to Thread
Results 1 to 2 of 2

Add/ Remove a specifc text string to a cell based on a checkbox

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    04-11-2012
    Location
    Chicago, IL
    MS-Off Ver
    Excel 2010
    Posts
    245

    Add/ Remove a specifc text string to a cell based on a checkbox

    Hello -

    Cell Ak6 in my worksheet is designed to capture free text entries. Users can input up to 300 characters. What I want to do is append the text string "Accessories Included" to cell AK6 when the user checks a checkbox in a user form. When the user unchecks the checkbox in the user form I want only the text string "Accessories included" to be removed from AK6 but not other text which may already reside in this cell. Below is the code I have so far but this merely adds the text string "Accessories included" to cell AK6 and overwrites anything that might already be resident in that cell. This code also does not remove "Accessories included" when the checkbox is unchecked.


    Private Sub CheckBox17_Click()
    
    'inserts "Accessories Included" in AK6 on sheet1
    If CheckBox17.Value = True Then Range("AK6").Value = "Accessories included"
    
    End Sub
    Thanks!

  2. #2
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Add/ Remove a specifc text string to a cell based on a checkbox

    Try this:

    Private Sub CheckBox1_Click()
    'inserts "Accessories Included" in AK6 on sheet1
    If CheckBox17.Value = True Then Range("AK6").Value = Range("AK6").Value & " Accessories included"
    If CheckBox17.Value = False Then Range("AK6").Value = Replace(Range("AK6").Value, " Accessories included", "")
    End Sub
    Please help by:

    Marking threads as closed once your issue is resolved. How? The Thread Tools at the top
    Any reputation (*) points appreciated. Not just by me, but by all those helping, so if you found someone's input useful, please take a second to click the * at the bottom left to let them know

    There are 10 kinds of people in this world... those who understand binary, and those who don't.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Remove duplicate characters from a text string in a cell
    By sam99 in forum Excel Formulas & Functions
    Replies: 13
    Last Post: 09-22-2020, 06:10 PM
  2. [SOLVED] Formula to remove smaller text string in cell
    By LightingPop in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 07-13-2013, 12:13 AM
  3. Replies: 3
    Last Post: 12-18-2012, 07:19 PM
  4. Write text to cell based on checkbox?
    By proepert in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-23-2010, 09:10 AM
  5. remove text before and/or after a string in a cell
    By hmatharo in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-21-2008, 09:57 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1