Textbox help
Manage your personal finances in Excel
Thanks Thanks:  0
Likes Likes:  0
Results 1 to 4 of 4

Thread: Textbox help

  1. #1
    MrExcel MVP Al Chara's Avatar
    Join Date
    Feb 2002
    Location
    Newark, Delaware
    Posts
    1,701
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

     
    Hi All,

    I have a number of text boxes that were created dynamically at run time. When they were created I had the background color set to red. Is there a way to have the background color yellow when the text box is being typed in and then turn green after it has been typed in.

    The textboxes are named mytextboxes(counter) where counter is a number from 1 to 100.

    The problem that I run into is that I cannot declare an on click action because the text boxes are created at run time.

    Any help would be greatly appreciated.

  2. #2
    MrExcel MVP
    Join Date
    Feb 2002
    Location
    Bogota, Colombia
    Posts
    11,959
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Well, you could take a look at this:

    http://www.cpearson.com/excel/vbe.htm

    to know how to add code dynamically, but, I think that it could create a mess. Another option, don't know how hard it will be (I'm guessing it will be less than the first option) would be to use a class module to do that.
    Regards,

    Juan Pablo González
    http://www.juanpg.com

  3. #3
    MrExcel MVP Al Chara's Avatar
    Join Date
    Feb 2002
    Location
    Newark, Delaware
    Posts
    1,701
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    I went to the site and couldn't find the link to adding code at run time. I am not too familiar with class modules. Can you post some sample code of how I can change the background color of any textbox if the textbox has been clicked and then change it to another color once it is not active anymore? Thank you for any help you can give.

  4. #4
    Legend NateO's Avatar
    Join Date
    Feb 2002
    Location
    Minneapolis, Mn, USA
    Posts
    9,700
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

      
    It's described here by Chip:

    Adding A Procedure To A Module

    The procedure below will add a new procedure called "MyNewProcedure" to the module named "NewModule" in ThisWorkbook.

    Sub AddProcedure()

    Dim VBCodeMod As CodeModule
    Dim LineNum As Long

    Set VBCodeMod = ThisWorkbook.VBProject.VBComponents("NewModule").CodeModule
    With VBCodeMod
    LineNum = .CountOfLines + 1
    .InsertLines LineNum, _
    "Sub MyNewProcedure()" & Chr(13) & _
    " Msgbox ""Here is the new procedure"" " & Chr(13) & _
    "End Sub"
    End With

    Application.Run "MyNewProcedure"

    End Sub

    Cheers, Nate

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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

 

 
DMCA.com