+ Reply to Thread
Results 1 to 7 of 7

Help w/ Unit Conversions

  1. #1
    Registered User
    Join Date
    09-24-2012
    Location
    Carlsbad, CA
    MS-Off Ver
    Microsoft Excel 2010
    Posts
    11

    Help w/ Unit Conversions

    Ok, so I think I've got this workbook where I want it to be for the most part. However, I've reached a hurdle that I can't seem to get over!

    I would like for the macro "Update Inventory" to subtract the value of C3 from the chosen inventory item in B2. Though since C3 is the result of converting (C2, D2, D3) the macro errors out if C3 = #N/A. This causes a problem where some of our materials are used by the dozen(dzn)! So what I'm having trouble with is making the macro work around the #N/A value and subtract the value of C2 from the chosen inventory item in B2 if there is no converted value in C3.

    Any help and/or advice is very much appreciated!
    Attached Files Attached Files
    Last edited by xxxombie88; 10-18-2012 at 04:22 PM.

  2. #2
    Registered User
    Join Date
    09-24-2012
    Location
    Carlsbad, CA
    MS-Off Ver
    Microsoft Excel 2010
    Posts
    11

    Re: Help w/ Unit Conversions

    bumping this since i made changes and don't feel it necessary to make a new thread

  3. #3
    Forum Contributor
    Join Date
    07-27-2012
    Location
    California, USA
    MS-Off Ver
    Excel 2003
    Posts
    198

    Re: Help w/ Unit Conversions

    How about this formula option.

    "=IF(C2>0,CONVERT(C2,D2,D3),0)"

  4. #4
    Registered User
    Join Date
    09-24-2012
    Location
    Carlsbad, CA
    MS-Off Ver
    Microsoft Excel 2010
    Posts
    11

    Re: Help w/ Unit Conversions

    that formula is fine, thank you! However I'm trying to get the VBA to argue "if C3 = #N/A then subtract C2 from 'Inventory'" but I can't seem to figure out where the VBA needs to be changed to allow this.

  5. #5
    Forum Contributor
    Join Date
    07-27-2012
    Location
    California, USA
    MS-Off Ver
    Excel 2003
    Posts
    198

    Re: Help w/ Unit Conversions

    I don't have a solution to your Excel version 2007 workbook. You have code
    for the worksheet change event and command button click event in two places,
    in Module1 and in code behind the Inventory sheet.

    My experience is with Excel 2003, so I'll leave it to the forum experts to
    say whether this duplication is a problem, and what code is working when the
    Update Inventory button is clicked or a sheet change event is triggered.

  6. #6
    Registered User
    Join Date
    09-24-2012
    Location
    Carlsbad, CA
    MS-Off Ver
    Microsoft Excel 2010
    Posts
    11

    Re: Help w/ Unit Conversions

    thanks for the help! i know the code is in "Module" and "Sheet" mainly because i was using the module on the final sheet and have been storing/logging the changes and updates i make to the code in a folder incase i decide to use the module for something else later. just a personal thing

    still haven't been able to put a code together that works around the #N/A value so until then i've had to designate "u" as "1dzn" (1 dozen) for the formula to work. i'd like to avoid this as some of our personnel may get confused, but if this is the only work around for what i'm trying to achive then meh i'm sure i can get my supervisor to allow it.

    also, pertaining to what i just mentioned, how would i be able to make it so a msgbox comes up saying "units don't match!" if the value of C3 = #N/A? haven't had luck since the cell contains a formula but this would help if anyone tries to run the macro with non-like units and keeps them out of the vba debug.


    thanks again for any help!
    Attached Files Attached Files

  7. #7
    Forum Contributor
    Join Date
    07-27-2012
    Location
    California, USA
    MS-Off Ver
    Excel 2003
    Posts
    198

    Re: Help w/ Unit Conversions

    Here's how to get the message out:

    Please Login or Register  to view this content.
    Sorry I can't be of more help. There are incompatibilities when I try
    to run the code from Excel 2003.

+ 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