+ Reply to Thread
Results 1 to 8 of 8

Code to Assign Pre-defined Number in separate Worksheet

  1. #1
    Registered User
    Join Date
    02-20-2009
    Location
    Mineral, VA
    MS-Off Ver
    Excel 2003
    Posts
    73

    Code to Assign Pre-defined Number in separate Worksheet

    Excel 2003: I need code that, when an "x" is entered in a cell in the "Activity" worksheet to assign a temporary unit #, it will look for the next available Temporary Unit # in the "Assign" worksheet. Then mark that unit # as "assigned" (by placing an "X" in the column next to it) and copy it to a cell in the "Activity" sheet.

    I will be doing the same thing with assigning different types of PO numbers. I figure if I have the code for the Unit #, I can use the same logic for the other assignments, with some modifications, of course.

    I've attached a sample workbook.

    If I am not considering the most effective way to accomplish what I am trying to do here, I have no ego at all about someone suggesting a better solution.
    Attached Files Attached Files
    Last edited by cedarhill; 04-27-2009 at 09:58 AM.

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Code to Assign Pre-defined Number in separate Worksheet

    Right-click on the ACTIVITY sheet tab and select VIEW CODE.

    Paste in this code:
    Please Login or Register  to view this content.
    Press Alt-Q to close the editor and save your sheet.
    You will have to have macros enabled from now on for this to work.

    Start putting Xs in and the assignments will occur.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Registered User
    Join Date
    02-20-2009
    Location
    Mineral, VA
    MS-Off Ver
    Excel 2003
    Posts
    73

    Re: Code to Assign Pre-defined Number in separate Worksheet

    Thank you very much. It works perfectly.

  4. #4
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Code to Assign Pre-defined Number in separate Worksheet

    Putting this in the "Activity" sheet's code module should work.
    Please Login or Register  to view this content.
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  5. #5
    Registered User
    Join Date
    02-20-2009
    Location
    Mineral, VA
    MS-Off Ver
    Excel 2003
    Posts
    73

    Re: Code to Assign Pre-defined Number in separate Worksheet

    The only problem with this code is that it automatically assigns the two separate PO # types as soon as I enter an "X" in the Assign Temp Unit # field. In many cases, we might assign a Unit # or a repair PO# or a purchase PO#...but rarely on the same activity line.

    Unfortunately, I'm not proficient enough with VBA to modify the code so that only when an "X" has been entered in the appropriate "assign" column associated with each type will it assign the type of number requested.

  6. #6
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Code to Assign Pre-defined Number in separate Worksheet

    Yes, my bad, I misread the posted sheet. Try this:
    Please Login or Register  to view this content.

  7. #7
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Code to Assign Pre-defined Number in separate Worksheet

    That's what my code in post #2 does. Try that.

  8. #8
    Registered User
    Join Date
    02-20-2009
    Location
    Mineral, VA
    MS-Off Ver
    Excel 2003
    Posts
    73

    Re: Code to Assign Pre-defined Number in separate Worksheet

    Yes, as I stated in my reply to Post #2, the logic worked perfectly. Also, I tested the 2nd code sample provided by mikerickson and that also will work. One of the great benefits of joining the forum is the education one gets in learning different paths to get to the same solution.

    One thing I do know for certain is that I have so much more I need to learn! Regardless...thanks to you both.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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