+ Reply to Thread
Results 1 to 8 of 8

Dynamic Textbox Naming Not Working

  1. #1
    Forum Contributor
    Join Date
    09-13-2012
    Location
    Midwest
    MS-Off Ver
    Excel 365
    Posts
    124

    Dynamic Textbox Naming Not Working

    My goal: Loop through a table, increasing row by i. When matching value is found, put value of BCX & i into a textbox called dest1. If BCX and i is empty, then BCW and i is used.
    My problem: I have textboxes dest1 to dest15. When dest1 is populated from the table, then I want the next match to use dest2, and so on.
    I tried the code below that I found, but I keep getting an error that closes Excel. The code looks very straight forward so I'm not sure what I'm doing wrong. It worked just fine until I tried the dynamic textbox names.
    Any help would be greatly appreciated. This is a critical process to making my whole userform practical. Thank you. -Luke

    Please Login or Register  to view this content.

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2407
    Posts
    26,095

    Re: Dynamic Textbox Naming Not Working

    No matter what problems might exist in code, a VBA error should never cause Excel to close. I don't see anything wrong with this code but all of the context is missing. How do you set lRow and tn? At what point does the error occur? Do you know how far it gets? I would try to identify the line causing the error by stepping through the code in the debugger. It would also help if you attach your file here with instructions for how to run your code and reproduce the error.

    The paper clip icon does not work for attachments. To attach a file, under the text box where you type your reply click the Go Advanced button. On the next screen scroll down and click on Manage Attachments, which will show a pop-up window to Select and Upload a file. Then close the window.
    Jeff
    | | |·| |·| |·| |·| | |:| | |·| |·|
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Valued Forum Contributor
    Join Date
    02-02-2016
    Location
    Indonesia
    MS-Off Ver
    Office 365
    Posts
    1,028

    Re: Dynamic Textbox Naming Not Working

    Untested by maybe this:

    Please Login or Register  to view this content.

  4. #4
    Forum Contributor
    Join Date
    09-13-2012
    Location
    Midwest
    MS-Off Ver
    Excel 365
    Posts
    124

    Re: Dynamic Textbox Naming Not Working

    6StringJazzer: lRow is the last row in my table. tn is a number that Im matching in the table. The code runs on initialize. It was working fine until I added the j loop to dynamically change the textbox name that receives the value from the table.

    Akuini: did not work.

    My error says that it cannot find the specified object. The textboxes are within 2 frames. The first frame is "outerframe". Within outerframe I have 15 different frames, each of them have the 15 different textboxes that I want to update. I tried the below code, but same error. Do I need to reference both frames, or just the frame that the textbox is in? Thanks. -Luke
    Please Login or Register  to view this content.

  5. #5
    Valued Forum Contributor
    Join Date
    02-02-2016
    Location
    Indonesia
    MS-Off Ver
    Office 365
    Posts
    1,028

    Re: Dynamic Textbox Naming Not Working

    You don’t need to reference the frame, what I was trying to say with the code I suggested is that your loop structure is wrong.
    Could you attach a sample workbook?

  6. #6
    Forum Contributor
    Join Date
    09-13-2012
    Location
    Midwest
    MS-Off Ver
    Excel 365
    Posts
    124

    Re: Dynamic Textbox Naming Not Working

    So, ummm, I figured out my own retardation but am too ashamed to admit what it was. Akuini, your code works just fine - thank you so much.

  7. #7
    Forum Contributor
    Join Date
    09-13-2012
    Location
    Midwest
    MS-Off Ver
    Excel 365
    Posts
    124

    Re: Dynamic Textbox Naming Not Working

    To be fair to those who have similar dumb issue, please name your controls what you aim to call them in your code.
    SMH, sorry for wasting anyone's time....

  8. #8
    Valued Forum Contributor
    Join Date
    02-02-2016
    Location
    Indonesia
    MS-Off Ver
    Office 365
    Posts
    1,028

    Re: Dynamic Textbox Naming Not Working

    You're welcome, glad to help, & thanks for the feedback.

+ 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] TextBox Naming & Value Input
    By gsandy in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-07-2018, 03:02 AM
  2. Naming a dynamic range
    By j_Southern in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-26-2015, 11:16 AM
  3. Dynamic file naming in VBA
    By dperry in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-04-2011, 02:22 PM
  4. dynamic naming of cells
    By gazerbeam in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 07-30-2008, 04:21 PM
  5. dynamic naming cells
    By excelsmu in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-31-2007, 01:08 PM
  6. Naming a dynamic range
    By matpj in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 10-02-2006, 09:24 PM
  7. Replies: 2
    Last Post: 04-24-2005, 12:06 AM

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