+ Reply to Thread
Results 1 to 8 of 8

How to pass a TextBox

  1. #1
    Registered User
    Join Date
    12-24-2010
    Location
    Manchester England
    MS-Off Ver
    Excel 2007
    Posts
    11

    How to pass a TextBox

    Dear Forum Members

    I need to change the Font and color of one or all of several textboxes if they have been left blank.
    I had hoped to do this by refering to a proceedure using code like this:_
    Please Login or Register  to view this content.
    Using tbWidth, Me.tbWidth, .tbWidth in the Call line all give error messages.
    The code in Sub ChangeFont works if written directly in the calling procedure
    Can anyone help please
    Ems
    Last edited by Emilysouth; 02-13-2011 at 05:56 PM.

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: How to pass a TextBox

    Untested
    Please Login or Register  to view this content.
    Post an example workbook if not
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: How to pass a TextBox

    Use no dimension, object or msforms.textbox

    Please Login or Register  to view this content.
    'Declarations can spoil more than you like'
    Last edited by snb; 02-13-2011 at 10:53 AM.



  4. #4
    Registered User
    Join Date
    12-24-2010
    Location
    Manchester England
    MS-Off Ver
    Excel 2007
    Posts
    11

    Re: How to pass a TextBox

    Dear Roy Uk
    Thanks for your post. The change does not work I get the error message
    "Type Mismatch"
    I will try snb's approach next and if I am still stuck will send a workbook
    John

  5. #5
    Registered User
    Join Date
    12-24-2010
    Location
    Manchester England
    MS-Off Ver
    Excel 2007
    Posts
    11

    Re: How to pass a TextBox

    Sadly none of the suggestions worked. I have prepared a workbook with the salient features and my original coding, which does not work.
    The code is fired by the "calculate" button. Numbers from the userform are then put into Sheet2 where the calculations are done. The results are then fed back to the userform.
    To guard against faulty calculations and Div by 0 problems I want to use the Sub RedText
    This also alerts the user as to which textbox he has missed.
    Ems
    Attached Files Attached Files

  6. #6
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: How to pass a TextBox

    I doubt your observations:

    Your code has the following faults:
    MyTextBox.Font=14 should be .Font.size=14
    MyTextBox.ForeColour=vbRed should be .Forcolor=vbred

    I hope you didn't continue/repeat them

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    12-24-2010
    Location
    Manchester England
    MS-Off Ver
    Excel 2007
    Posts
    11

    Re: How to pass a TextBox

    snb
    Thanks for your input. The code faults you found were typos as i couldn't just copy and paste.
    The actual code was as you advised, American spelling and all.
    I will be trying again later tonight and will let you know how I get on tomorrow.
    Ems

  8. #8
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: How to pass a TextBox

    Hello EMS,

    This macro will mark any TextBox that is empty with the 3 asterisks in red font.
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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