+ Reply to Thread
Results 1 to 3 of 3

Insert string in active text box only

  1. #1
    Forum Contributor
    Join Date
    11-10-2009
    Location
    Perth, Australia
    MS-Off Ver
    Excel 2007
    Posts
    549

    Insert string in active text box only

    I have this macro which takes a variable number of selected cells and puts them in a form. There is a button which inserts the character "#" at the cursor location.
    If I place the cursor in the first textbox it will work, it will insert the character at the cursor location. When I get to the second and subsequent textboxes, it REMEMBERS the cursor location from the previous selection and it will insert the character in the previous textboxes again, even though the cursor is not there. So by the "n-th" textbox selection, it will insert the character in all "n" textboxes. I only want to insert the character in the text box where the cursor is.
    Is there a way to specify the active textbox only?

    BeforeAndAfter.png

    FORM CODE
    Please Login or Register  to view this content.
    Attached Images Attached Images
    Attached Files Attached Files

  2. #2
    Registered User
    Join Date
    12-14-2012
    Location
    Czech Republic
    MS-Off Ver
    Excel 2010
    Posts
    92

    Re: Insert string in active text box only

    Hi,

    there is not any gotfocus event for textbox. Once you click the button a textbox is not the active control... My opinion is that it is not possible to do it in excel userform or would be bit difficult task.

    If the goal is to insert some (same) string to the position of a cursor in each box then I'd put a mark (like #) to every box manually. And under Button use replace method.

    s.

  3. #3
    Forum Contributor
    Join Date
    11-10-2009
    Location
    Perth, Australia
    MS-Off Ver
    Excel 2007
    Posts
    549

    Re: Insert string in active text box only

    You're right.
    There is an example here which uses module classes: http://yoursumbuddy.com/raiseevent-m...form-controls/
    But this if when textbox is written into. I can't exactly use this one because I will have characters that can't be typed in.

+ 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] Insert text from one cell into a string of text in another
    By DianeP in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 09-24-2015, 11:42 AM
  2. [SOLVED] Look for specific text string, insert row below, insert text to that row
    By jwats in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-19-2015, 03:08 PM
  3. Macro that will insert a simple text string in top cell of text file
    By Davek11 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-25-2014, 07:31 PM
  4. [SOLVED] Insert Row under cell containing text on entire active sheet
    By mgeddes in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 11-04-2013, 07:04 AM
  5. [SOLVED] Insert a piece of text to all active worksheets after the last cell with data in it
    By boomboomblock in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-15-2013, 07:22 AM
  6. [SOLVED] Insert a piece of text to all active worksheets
    By boomboomblock in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-15-2013, 05:41 AM
  7. Excel 2007 : Insert Text into string
    By skidz in forum Excel General
    Replies: 5
    Last Post: 11-12-2010, 12:56 PM

Tags for this Thread

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