+ Reply to Thread
Results 1 to 7 of 7

UserForm (QTY) TextBox, Increment by batch (QTY) and add to Cells on Sheet

  1. #1
    Registered User
    Join Date
    05-27-2016
    Location
    England
    MS-Off Ver
    2010
    Posts
    48

    UserForm (QTY) TextBox, Increment by batch (QTY) and add to Cells on Sheet

    Hi,

    I have a (Batch QTY) TextBox on a userform, When i click the add button i need to increment the QTY onto my excel sheet called "Dump" to cell "B2" (B1 is the header)
    The QTY needs to start at 12 and with a prefix of "OS" (OS012 up to OS256), As you can see the code needs to change the prefix from "OS0" for 2 digit number and "OS" for 3 digit number inputs from the TextBox

    e.g. if have a (Batch QTY) of 100 in the TextBox when the add button is clicked, i need to send:
    "OS012 to cell "B2", "OS013 to cell "B3" down to "OS121" to cell "B101"



    This is what i have so far.
    HTML Code: 
    TIA

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,946

    Re: UserForm (QTY) TextBox, Increment by batch (QTY) and add to Cells on Sheet

    You don't need to cater for 2 or 3 digits. Try this:

    Please Login or Register  to view this content.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,946

    Re: UserForm (QTY) TextBox, Increment by batch (QTY) and add to Cells on Sheet

    This doesn't make sense:

    i need to send: "OS012 to cell "B2", "OS013 to cell "B3" down to "OS121" to cell "B101"

  4. #4
    Registered User
    Join Date
    05-27-2016
    Location
    England
    MS-Off Ver
    2010
    Posts
    48

    Re: UserForm (QTY) TextBox, Increment by batch (QTY) and add to Cells on Sheet

    Hi TMS,

    I dont think i made my self very clear. I need to add 1 batch of numbers in each Workbook.
    lets say the batch Qty is "10", I type the batch QTY of 10 and click add i need to add the prefix and add them to my sheet called "Dump". (OS012 cell B2, OS013 cell B3, OS014 cell B4, OS015 cell B5, OS016 cell B6, OS017 cell B7, OS018 cell B8, OS019 cell B9, OS020 cell B10, OS021 cell B11)

    When the sheet is reset the next batch could be 150, again Must start at OS012 and will end with OS162 (12 + Batch number)

    Prefix (must always start at 12, e.g. OS012 + Batch QTY

  5. #5
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,946

    Re: UserForm (QTY) TextBox, Increment by batch (QTY) and add to Cells on Sheet

    It was clear enough. That's what the code example does. Starts at OS012 in cell B2 and works up to whatever. The point is, you don't need to worrk about how many digits there may be. If, say, you had 1000 entries, you'd need another test.

    Did you try the example code?

    e.g. if have a (Batch QTY) of 100 in the TextBox when the add button is clicked, i need to send:
    "OS012 to cell "B2", "OS013 to cell "B3" down to "OS121" to cell "B101"
    If you have a batch quantity of 100, you don't get OS121 in cell B101, you get OS111 ... B2=OS012, B3=013, ... B99=OS109, ... B100=OS110, B101=OS111

  6. #6
    Registered User
    Join Date
    05-27-2016
    Location
    England
    MS-Off Ver
    2010
    Posts
    48

    Re: UserForm (QTY) TextBox, Increment by batch (QTY) and add to Cells on Sheet

    Hi TMS,

    I have tested the code. it is doing as you say, but i only need to add the QTY i am inputting in to the TextBox (e.g. if i enter 10 as a QTY i only want 10 outputted to the sheet), if i have more it messes up all my data on other sheets (as it now thinks i have added over 130 in one batch)

    if i enter 10, i want 10 on the sheet. If i enter 20 i want 20 on the sheet.

    TIA

  7. #7
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,946

    Re: UserForm (QTY) TextBox, Increment by batch (QTY) and add to Cells on Sheet

    It's only intended to demonstrate the principle. You should adapt it for your needs.

+ 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. copy text from userform textbox to sheet textbox
    By Dfrost in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-28-2015, 02:19 AM
  2. [SOLVED] Conditional format - Can Cells on a sheet have the same conditions as a textbox Userform?
    By JJFletcher in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-16-2014, 06:11 PM
  3. Userform textbox & sheet cells date format do not match
    By KK1234 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-28-2014, 12:56 PM
  4. [SOLVED] UserForm SpinButton to increment Time after TextBox Entry
    By GRazor71 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-02-2013, 01:10 PM
  5. Replies: 0
    Last Post: 06-19-2012, 11:36 AM
  6. Move userform TextBox entries to cells on a sheet
    By rkjudy in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 01-09-2011, 10:33 AM
  7. Batch replace cells in whole sheet
    By sino in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 10-27-2010, 09:42 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