+ Reply to Thread
Results 1 to 3 of 3

Text box to equal cell value in VBA Form

  1. #1
    Registered User
    Join Date
    08-24-2012
    Location
    Boston, MA
    MS-Off Ver
    Excel 2010
    Posts
    5

    Text box to equal cell value in VBA Form

    Hi all,

    I am a bit of a novice in vba and am trying to fix an issue that I can't quite wrap my head around despite extensive research. I would love for you guys to give me your thoughtful advice.

    I am basically working with a model that enables the user to change assumptions and get an updated forecast based on their new inputs. I have created a form as a front-end that has different labels and text-boxes referencing cells in the back-end excel worksheet. For example i have:

    Please Login or Register  to view this content.
    So when the user changes NonFarmCAGR1, he should see nonfarm1value grow or decrease accordingly. Now since it is a CAGR, I have formatted the nonfarmcarg1 textbox as a percentage instead of having it displaying a number with 16 decimals. using the following code:
    Please Login or Register  to view this content.
    So the problem I am running into is that when I have the event that says: when nonfarmcagr changes
    Please Login or Register  to view this content.
    , if the user just clicked and actually didn't change anything the value gets rounded and the forecast therefore slighty changes. For exemple if the base value is 0.0161616 that is displayed 1.62%, if the user click, the value in cell D6 will become
    0.0162. I have try using if statements and rounds but I couldn't figure it out.

    Additionally D6 actually reference another cell N6, and when the user click and doesn't actually change the value, it would be even better if the formula in D6 stayed "=N6" instead of becoming the value 0.0161616.

    Any thoughts on what I could implement?

    Thanks in advance,

    Thi

    FYI, I tried something like this, which wasn't quite working and seems over complicated to me:
    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
    MS365 Family 64-bit
    Posts
    24,691

    Re: Text box to equal cell value in VBA Form

    I'm rather confused about your overall scenario. You are filling in the textbox based on the rounded value of D6, then if the textbox changes you are copying that rounded value back to D6. Well, when you fill in the textbox that triggers a change, therefore every time you copy D6 into the textbox the value will get copied back to D6. So why are you copying it from the textbox when you want the same value that's already there?

    This problem would be much clearer if you could post your file and explain how this works from the user's point of view.

    Edit: I read through this again, and got a little more out of it. The real problem is that when you put data into a text box, you see exactly what's in the box. It's not like when you have data in a cell but it can display a rounded value. So you need to have somewhere else to store the full value that you are showing in the text box. I suggest you use a variable declared as Double globally in the form code to mirror the value shown as rounded in the textbox. Posting your file would help.
    Last edited by 6StringJazzer; 10-03-2013 at 08:55 PM.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Registered User
    Join Date
    08-24-2012
    Location
    Boston, MA
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Text box to equal cell value in VBA Form

    Hey 6StringJazzer,

    Thank you very much for your answer. I will look into using a variable declared as Double.

    Unfortunately, I can't share with you the original file due to proprietary reasons. I have however put together a file that mimics it that I am attaching to that post.

    Please feel free to give me your thoughts.

    Thanks again,

    Thi
    Attached Files Attached Files

+ 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. Replies: 1
    Last Post: 08-28-2013, 05:04 PM
  2. How to make cell values equal certain text depending on other cells' text
    By Wes Borland in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 03-28-2013, 02:08 PM
  3. Replies: 5
    Last Post: 07-12-2012, 07:15 PM
  4. Text to equal value in separate cell
    By CHLOEMEIERS in forum Excel General
    Replies: 2
    Last Post: 05-22-2012, 10:56 PM
  5. Cell equal to another one but appearing in text
    By mikla in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-25-2006, 02:55 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