+ Reply to Thread
Results 1 to 5 of 5

If cell has a formula, copy text to TextBox and leave formula unchanged in cell

  1. #1
    Registered User
    Join Date
    05-21-2014
    Location
    Auckland New Zealand
    MS-Off Ver
    2013
    Posts
    35

    If cell has a formula, copy text to TextBox and leave formula unchanged in cell

    Hi There.

    I am trying to transfer the text in a cell over to a user form textbox but it replaces the cell with the text and overwrites the formula.
    The TextBox control source is blank and the following code is in the TextBox Change event.

    Please Login or Register  to view this content.
    This code simply overwrites the formula after it changes the textbox. any ideas?

  2. #2
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,528

    Re: If cell has a formula, copy text to TextBox and leave formula unchanged in cell

    Your backslash [\code] needs to be changed to a forward (/) slash
    Your code says that if you do change something in the textbox (TextBox1_Change()), whatever is in the textbox should be put in Cell Z2.
    You ask for the other way around, is that right. How do you want this to do that? When the Userform opens (initialize)?

    The value of Cell Z2 will be in TextBox1 when you open the Userform.
    Please Login or Register  to view this content.
    Last edited by jolivanes; 09-01-2016 at 05:24 PM.

  3. #3
    Registered User
    Join Date
    05-21-2014
    Location
    Auckland New Zealand
    MS-Off Ver
    2013
    Posts
    35

    Re: If cell has a formula, copy text to TextBox and leave formula unchanged in cell

    Hi Jolivanes.

    Yeah saw my mistake and edited it 2 seconds later. .../...

    I am trying to populate the TextBox from Cell "Z2" without overwriting the formula that is in cell "Z2"

    Perhaps I shouldn't be using a textbox as I am not wanting to have text entered into it.

  4. #4
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,528

    Re: If cell has a formula, copy text to TextBox and leave formula unchanged in cell

    The code I gave you will populate the textbox on the userform with the value, not the formula, from cell Z2 as soon as you open the userform.
    If you want it done differently, you have to let us know.
    Have you tied the code?

  5. #5
    Registered User
    Join Date
    05-21-2014
    Location
    Auckland New Zealand
    MS-Off Ver
    2013
    Posts
    35

    Re: If cell has a formula, copy text to TextBox and leave formula unchanged in cell

    Awesome Jolivanes.

    I now see that this has to happen on the initialise event and not in the textbox change event.
    It works great and now when the cell changes due to the formula calculating it also changes on the UserForm.

    The answer to my thread is ' your code must be put in the "UserForm_Initialize()" event

+ 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: 2
    Last Post: 10-24-2014, 12:12 PM
  2. Replies: 2
    Last Post: 03-24-2014, 06:02 PM
  3. [SOLVED] countif formula changes cell values and cell reference is unchanged
    By KK1234 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-24-2014, 11:37 AM
  4. copy range with formula unchanged
    By jackyan in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 10-03-2008, 05:40 PM
  5. [SOLVED] how do I leave cell content unchanged if a condition is not met
    By darkelf26 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-10-2006, 12:45 PM
  6. [SOLVED] Textbox text into cell as formula
    By Zone in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-11-2006, 01:40 PM
  7. [SOLVED] How to keep a cell ref in formula unchanged when the ref cell move
    By Clifton Ford in forum Excel General
    Replies: 2
    Last Post: 03-14-2006, 01:10 PM

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