+ Reply to Thread
Results 1 to 16 of 16

help to convert textbox value to negative based on another textbox value

  1. #1
    Registered User
    Join Date
    05-10-2013
    Location
    montreal
    MS-Off Ver
    Excel 2010
    Posts
    20

    help to convert textbox value to negative based on another textbox value

    Trying to figure out the else if and not even coming close.

    What I am trying to accomplish if texbox1 value = "stock: then it will take textbox1 and
    fill the cell with a positive number . If textbox1 = 123456 or any number that is not "stock"
    it would put that cell as negative. I need to do this for textbox 2 to textbox10

    code below works to put it into the worksheet until I tried to play with the else .
    As you can see totaly new to this

    Please Login or Register  to view this content.
    Thanks in advance if anyone wishes to help me.
    Lewis

  2. #2
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: help to convert textbox value to negative based on another textbox value

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    05-10-2013
    Location
    montreal
    MS-Off Ver
    Excel 2010
    Posts
    20

    Re: help to convert textbox value to negative based on another textbox value

    Must have done something wrong as all I am getting on anything other than "stock"
    is negative 1 in column 3 (instead of the negative value of what was inputted into
    the userform textbox2 (But I'm a step closer it think lol.

    Thanks again Ragulduy but can you see what I did wrong. Code snippet below .

    Please Login or Register  to view this content.

  4. #4
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: help to convert textbox value to negative based on another textbox value

    Sorry, I misread what you wanted, change:
    Please Login or Register  to view this content.
    to
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    05-10-2013
    Location
    montreal
    MS-Off Ver
    Excel 2010
    Posts
    20

    Re: help to convert textbox value to negative based on another textbox value

    AMAZING thank you so much.
    Now just need to copy this loop for 10 textboxes lol.

  6. #6
    Registered User
    Join Date
    05-10-2013
    Location
    montreal
    MS-Off Ver
    Excel 2010
    Posts
    20

    Re: help to convert textbox value to negative based on another textbox value

    oops spoke to fast just tested one with the text stock and it also came negative lol.

    this is what I have now did I muck it up ?

    Please Login or Register  to view this content.

  7. #7
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: help to convert textbox value to negative based on another textbox value

    you changed:
    Please Login or Register  to view this content.
    to
    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    05-10-2013
    Location
    montreal
    MS-Off Ver
    Excel 2010
    Posts
    20

    Re: help to convert textbox value to negative based on another textbox value

    your right and it works when I put it back to 5.
    Can you tell me what the value,5 means I thought it was in reference to the column number which was 3 and
    of course I am wrong.

    Thanks again for your time

  9. #9
    Registered User
    Join Date
    05-10-2013
    Location
    montreal
    MS-Off Ver
    Excel 2010
    Posts
    20

    Re: help to convert textbox value to negative based on another textbox value

    only ask because when I tried to do the next set and put the value,5 it didn't work.
    The first column works to be positive if "stock" appears but second column always goes negative when it says "stock"

    Please Login or Register  to view this content.

  10. #10
    Registered User
    Join Date
    05-10-2013
    Location
    montreal
    MS-Off Ver
    Excel 2010
    Posts
    20

    Re: help to convert textbox value to negative based on another textbox value

    oops sorry see my error. with the second set

  11. #11
    Registered User
    Join Date
    05-10-2013
    Location
    montreal
    MS-Off Ver
    Excel 2010
    Posts
    20

    Re: help to convert textbox value to negative based on another textbox value

    Can I ask you another question since you have helped me so much.

    What if I want to have a checkbox for Stock and when you click
    on the checkbox for stock it would fill in .Cells(NextRw, 1).Value with the word stock (instead of having to type it in) and continue your loop with cells being positive.




    Is this complicated to do ?

  12. #12
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: help to convert textbox value to negative based on another textbox value

    Hi - the LEFT(a,b) function takes the string a and returns the first b letters. So it returns the first 5 letters of whatever is in the textbox and compares it to "stock".

    I'd suggest posting another thread for your new question.

  13. #13
    Registered User
    Join Date
    05-10-2013
    Location
    montreal
    MS-Off Ver
    Excel 2010
    Posts
    20

    Re: help to convert textbox value to negative based on another textbox value

    your right I will post another thread for the other question.

    I do have something happening weird now. the positive based on stock or negative based on anything else is working perfect but the code you gave me affected code elsewhere on my userform.

    The userform1 was totaling the textboxes and it works fine still but as soon as I click add I get an error.

    the userform code that works on userform display but mucks up your code is .

    Please Login or Register  to view this content.
    and the error on submit goes to this line with a type mismatch.

    .Cells(NextRw, 5).Value = -UserForm1.TextBox4.Value

    Is there something I need to change in the userform subtotal to match your new code ?

  14. #14
    Registered User
    Join Date
    05-10-2013
    Location
    montreal
    MS-Off Ver
    Excel 2010
    Posts
    20

    Re: help to convert textbox value to negative based on another textbox value

    btw I only get the error if I do not enter "stock" . If I enter "stock there is no error when clicking add"

  15. #15
    Registered User
    Join Date
    05-10-2013
    Location
    montreal
    MS-Off Ver
    Excel 2010
    Posts
    20

    Re: help to convert textbox value to negative based on another textbox value

    sorry I have some typos causing my problems. Again thanks for the help.

  16. #16
    Registered User
    Join Date
    05-10-2013
    Location
    montreal
    MS-Off Ver
    Excel 2010
    Posts
    20

    Re: help to convert textbox value to negative based on another textbox value

    I'm still having an issue even though I double checked I have no typos.

    code works as long as I start from the first column and do not skip any.
    but the minute I skip a column I get a type mismatch error.

    to explain :
    column 1 is either a po number or the term stock (adjust numbers positive or negative)
    column 2 is the date
    column 3 is first size
    column 4 is second size
    etc

    so as long as I do not skip column 1,2,3,4 it works perfect but if I add
    to column 1,2 skip 3 and put a qty in column 4 it bombs.


    can anyone see what I did wrong.
    code below...
    Please Login or Register  to view this content.

+ 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: 4
    Last Post: 01-29-2014, 05:53 AM
  2. Set Max and Min limits on calculated textbox based on another textbox entry
    By kpinkerman in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-13-2013, 04:54 PM
  3. Replies: 3
    Last Post: 05-07-2012, 09:46 PM
  4. [SOLVED] Textbox fomatting value based on another textbox
    By job in forum Excel General
    Replies: 2
    Last Post: 02-02-2005, 01:06 PM

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