+ Reply to Thread
Results 1 to 5 of 5

Creating a macro (or module) to modify a cell's value based on automated entries

  1. #1
    Registered User
    Join Date
    10-20-2012
    Location
    salinas, ca
    MS-Off Ver
    Excel 2010
    Posts
    25

    Post Creating a macro (or module) to modify a cell's value based on automated entries

    Hello All,

    I'm in need of your vast expertise to resolve a problem I have with a userform I created in Excel 2010. The form collects information from a label via scanning (two scans of the same label, the first one for the Item ID (restricted to seven characters in the text box) and the second one for the Item P.O. (all fourteen characters of the label)).
    The first scan output is placed in cell B14, then is validated by a table and the Item ID info is displayed in cell C14, the output for the second scan is placed in cell D14, gets validated and the Item P.O. info is displayed in cell E14; the process goes on and covers a range of B14:E28. The problem I'm facing is that I need to make the process of displaying both the Item ID and Item P.O. work with only one scan instead of two, so that the single scan can validate two entries with different length requirements in different cell targets.
    I'm looking for your help to come up with a macro or a module that either restricts the number of characters in the first cell (B14:B28) or modifies the data in the second cell (D14:D28) to seven characters and then places the modified data in the first cell, without changing the data in the second cell or putting a formula in the first cell.
    Please let me know if you need more information on either the process or the aim of the macro/module and I'll post the required info. Thank you in advance for any help you can provide.
    Last edited by Julez80s; 10-21-2012 at 05:26 AM.

  2. #2
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Creating a macro (or module) to modify a cell's value based on automated entries

    Hi, Julez80s,

    have you tried assigning the contents of trhe scan to a variable and then using Left(yourVariable, 7) for filling the first box?

    Sample for getting the idea:
    Please Login or Register  to view this content.
    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  3. #3
    Registered User
    Join Date
    10-20-2012
    Location
    salinas, ca
    MS-Off Ver
    Excel 2010
    Posts
    25

    Re: Creating a macro (or module) to modify a cell's value based on automated entries

    Thanks for the quick reply, Holger!
    Of all the things I thought about doing... variables were the last! DAMN VARIABLES!!!! (<---- shaking his fist to the heavens)
    I'm still having some trouble declaring the variable, though. I've tried using each of the text boxes (txtItem and txtBatch) but neither has worked the way I need it to. The first one doesn't give me an output on the first cell and the second one doesn't restrict the amount of characters in the cell. Do I need to change the way the form works in order to get the output formatted by the variable subroutine?
    Here's the original form:
    Please Login or Register  to view this content.
    Any help with this issue is greatly appreciated!

  4. #4
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Creating a macro (or module) to modify a cell's value based on automated entries

    Hi, Julez80s,

    itīs easy for me to tell what to do if I donīt know how the data is comning into the form (and what data in which form).

    The first one doesn't give me an output on the first cell
    Letīs add a check for the length of the text in that textbox (you may change it to your needs, here is just for any information at all):
    Please Login or Register  to view this content.
    Ciao,
    Holger

  5. #5
    Registered User
    Join Date
    10-20-2012
    Location
    salinas, ca
    MS-Off Ver
    Excel 2010
    Posts
    25

    Cool Re: Creating a macro (or module) to modify a cell's value based on automated entries

    SUCCESS!!

    Thanks for the help, Holger!!

    I had to tweak your suggestion a bit but it worked perfectly! I will have to add a description of the item to the form since there will be only one box now, and the user may not be able to distinguish the item number from the label scan, but at least the hardest part of the change has been accomplished thanks to you.

    Again... thank you for the help on this one!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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