+ Reply to Thread
Results 1 to 7 of 7

Adding Input Box Value into Formula

  1. #1
    Registered User
    Join Date
    04-05-2024
    Location
    Washington, USA
    MS-Off Ver
    Office 365
    Posts
    16

    Adding Input Box Value into Formula

    I have a formula that will be implemented into a cell and copied down the column which works for the other types of pricing rules, but this one in particular doesn't seem to be working. As far as I can tell, it is the Cost Multiplier part. Do I need to declare the input box values as anything? Am I putting the Cost Multiplier into the formula wrong? Any help would be greatly appreciated. Thank you

    Please Login or Register  to view this content.
    Admin note: Please put code directly into your post instead of having us download a text file to see it. --6SJ
    Attached Files Attached Files
    Last edited by jonathanramey; 04-19-2024 at 06:51 PM.

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Adding Input Box Value into Formula

    this one in particular doesn't seem to be working
    What are you expecting it to do, and what does it do instead?

    Consider attaching the Excel file so we can actually run your code and see what's going on.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Registered User
    Join Date
    04-05-2024
    Location
    Washington, USA
    MS-Off Ver
    Office 365
    Posts
    16

    Re: Adding Input Box Value into Formula

    I cannot attach the excel file as there is some sensitive information in there. The error that I get from VBA after running that line is Run time error 1004. Application-defined or object-defined error. I am wanting this part of the code to implement a formula in a specific cell. Variations of this formula has worked, but this one is different in that it has a input box because it needs a specific value. When I debug the error, it highlights the both of the lines for the formula.

  4. #4
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Adding Input Box Value into Formula

    That error indicates, in this case, that the formula is not valid. If you were trying to enter the exact same thing directly into the cell you would get a message from Excel that the formula is invalid.

    It's not possible for me to know what's wrong unless I can see all the values referenced in your code at runtime, and I can't see that without your file.

    I would suggest you do this:

    Add this at the beginning of your Sub
    Please Login or Register  to view this content.
    Replace the line you showed with these three lines:
    Please Login or Register  to view this content.
    Bring up the Immediate Window before running the code, then see what formula it prints before trying to assign it to the cell. If you can't tell from that what's wrong with your formula, then post that result here for further analysis.

  5. #5
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,530

    Re: Adding Input Box Value into Formula

    Re: "some sensitive information in there"
    Some people have reported that using the delete key together with the other keys on the keyboard to type in fictitious data has actually worked wonders.
    Of course it takes some time.

    Tongue firmly in cheek here.
    Experience trumps academics every day of the week and twice on Sunday.

  6. #6
    Registered User
    Join Date
    04-05-2024
    Location
    Washington, USA
    MS-Off Ver
    Office 365
    Posts
    16

    Re: Adding Input Box Value into Formula

    I did as you suggested and the following shoes up in the immediate window

    Please Login or Register  to view this content.
    When I run the rest of the code line by line, I get to the last line of your suggestion and the same error message shows up as before, the 1004. Correct me if I am wrong, but to me, this would suggest that something is wrong with the following portion, not the formula itself, which does not make sense to me as it works with other more basic formulas.

    Please Login or Register  to view this content.

  7. #7
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Adding Input Box Value into Formula

    The fact that it works with more basic formulas is exactly the reason that the problem points to the formula. The last line of code is where it tries to put the formula into the cell.

    If you copy that formula and try to paste it into a cell, you will get an error that it is an invalid formula.

    You have a stray single quote mark. Scroll to the right to see it. If you remove it you will have a valid formula. I have no idea if it will give you the result you want, but it will be valid and will eliminate the VBA error.
    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. Adding input into cell
    By morpheus83uk in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-11-2020, 04:55 PM
  2. Replies: 1
    Last Post: 02-24-2013, 06:27 PM
  3. [SOLVED] Adding Input box to VBA code
    By The Drone in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-16-2012, 08:27 PM
  4. Automatic Formula Input Based on User Input Using a Macro
    By Drayloc in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-03-2012, 12:10 PM
  5. Adding to an input box
    By wildcats0625 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-28-2010, 10:28 PM
  6. adding 1 hour to input box
    By srroduin in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 04-13-2006, 04:40 PM
  7. Adding input to macro
    By cappuccine in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-04-2005, 08:50 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