Consulting

Results 1 to 3 of 3

Thread: Clear Textbox with more than 256 characters

  1. #1
    VBAX Contributor Glaswegian's Avatar
    Joined
    Sep 2004
    Location
    Glasgow, Scotland
    Posts
    196
    Location

    Clear Textbox with more than 256 characters

    I have a Textbox on a sheet and I've provided users with a button to clear the text. There is often more than 256 characters in the text and my first macro only clears the textbox if the users click the button until clear. I'm aware that there is a 256 character limit for such things as copying between textboxes, but just wondering if there is a more efficient way to clear a textbox. Here is my first code

    Sub clearFileNotes()
    ActiveSheet.TextBoxes("Text Box 12").Characters.Text = ""
    Range("A1").Select
    End Sub
    I then tried this but it keeps leaving a few characters - and is probably not very efficient

    Sub ClearAllFileNotes()
    Dim txtBox As TextBox
    Dim x As Integer
    Set txtBox = ActiveSheet.TextBoxes("Text Box 12")
    For x = 1 To txtBox.Characters.Count
        txtBox.Characters(x).Text = ""
    Next
    End Sub

    Just curious if there is a faster/more efficient way to clear the text in one go.

    Thanks for your help.
    Iain - XL2010 on Windows 7

  2. #2
    VBAX Newbie
    Joined
    Nov 2004
    Posts
    2
    Location
    How strange. This'll do it (I think):-

    ActiveSheet.TextBoxes("Text Box 12").Text = ""
    Lindon

  3. #3
    VBAX Contributor Glaswegian's Avatar
    Joined
    Sep 2004
    Location
    Glasgow, Scotland
    Posts
    196
    Location

    Clear Textbox with more than 256 characters-SOLVED

    Hi Lindon

    Yep - works nicely - don't know why I didn't consider that, but thanks anyway.

    Regards
    Last edited by Glaswegian; 11-16-2004 at 05:32 AM. Reason: Amend to resolved
    Iain - XL2010 on Windows 7

Posting Permissions

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