+ Reply to Thread
Results 1 to 18 of 18

Button to display a formula result in a different cell

  1. #1
    Registered User
    Join Date
    01-23-2011
    Location
    ontario, canada
    MS-Off Ver
    Excel 2003
    Posts
    10

    Button to display a formula result in a different cell

    I'd like to insert a button on a spreadsheet that, when pressed will use a formula to calculate a result and display that result in a different cell. Before that button is pressed though, I'd like the destination cell to display some text.

    The formula I'd like the button to calculate is =PROPER(TEXT((TODAY()+'DATA CALC''S'!G16),"MMM DD, YYYY"))

    The destination cell is I14.

    Thanks in advance to anyone that helps!
    Last edited by boogeyman; 01-23-2011 at 01:03 AM.

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Button to display a formula result in a different cell

    Hello boogeyman,

    Welcome to the Forum!

    Here is the button macro...
    Please Login or Register  to view this content.

    Adding the Macro
    1. Copy the macro above pressing the keys CTRL+C
    2. Open your workbook
    3. Press the keys ALT+F11 to open the Visual Basic Editor
    4. Press the keys ALT+I to activate the Insert menu
    5. Press M to insert a Standard Module
    6. Paste the code by pressing the keys CTRL+V
    7. Make any custom changes to the macro if needed at this time.
    8. Save the Macro by pressing the keys CTRL+S
    9. Press the keys ALT+Q to exit the Editor, and return to Excel.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Registered User
    Join Date
    01-23-2011
    Location
    ontario, canada
    MS-Off Ver
    Excel 2003
    Posts
    10

    Re: Button to display a formula result in a different cell

    That's great!
    It's putting the date in there perfectly!
    Just to tweak it a little more though....
    Is there any way to have a few words in the destination cell (I14) if the user hasn't pressed the button yet? Sort of a reminder that they haven't performed that calculation yet...
    Like a default phrase that gets replaced by the date when the button is pressed, but reloads to the default phrase everytime the workbook is opened.
    Thanks a million for the speedy, detailed response!
    It is really, really appreciated!

    P.S. should AutoLoad be set to true or false?
    Last edited by boogeyman; 01-23-2011 at 10:02 AM.

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Button to display a formula result in a different cell

    Hello boogeyman,

    The Workbook_Open() event can load a default value into the cell. You may need to change the worksheet name to match your sheet's name. Change the default text to what you want.
    Please Login or Register  to view this content.

    How to Save a Worksheet Event Macro
    1. Copy the macro using CTRL+C keys.
    2. Open your Workbook and Right Click on the Worksheet's Name Tab for the Worksheet the macro will run on.
    3. Left Click on View Code in the pop up menu.
    4. Paste the macro code using CTRL+V
    5. Make any custom changes to the macro if needed at this time.
    6. Save the macro in your Workbook using CTRL+S

  5. #5
    Registered User
    Join Date
    01-23-2011
    Location
    ontario, canada
    MS-Off Ver
    Excel 2003
    Posts
    10

    Re: Button to display a formula result in a different cell

    Hey Leith!
    Let me start by saying that I really appreciate your help with this.
    I have been banging my head against the wall for days trying to figure this out myself.
    I seem to be doing something wrong when I cut and paste your most recent code.
    I get an error "Invalid outside procedure" error and it has highlighted my default text.
    Is it important where in the sequence I paste this code?
    Sorry if my questions are stupid or very basic but I'm kinda new at this.

  6. #6
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Button to display a formula result in a different cell

    Hello boogeyman,

    That is my fault. I posted the wrong installation procedure! Let's try this again. Delete the previous macro code from your workbook and let's start again.
    Please Login or Register  to view this content.

    How to Save a Workbook Event Macro
    1. Copy the macro using CTRL+C keys.
    2. Open your Workbook and Right Click on any Worksheet's Name Tab
    3. Left Click on View Code in the pop up menu.
    4. Press ALT+F11 keys to open the Visual Basic Editor.
    5. Press CTRL+R keys to shift the focus to the Project Explorer Window
    6. Press the Down Arrow Key until ThisWorkbook is highlighted in blue.
    7. Press the Enter key to move the cursor to the Code Window
    8. Paste the macro code using CTRL+V
    9. Save the macro in your Workbook using CTRL+S

  7. #7
    Registered User
    Join Date
    01-23-2011
    Location
    ontario, canada
    MS-Off Ver
    Excel 2003
    Posts
    10

    Re: Button to display a formula result in a different cell

    No problem!
    But, isn't this code exactly the same as the last one?
    I tried it and I'm getting the same error.

  8. #8
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Button to display a formula result in a different cell

    Hello boogeyman,

    Post your workbook so I can review what is happening. If everything is where it should be then there should be no errors.

  9. #9
    Registered User
    Join Date
    01-23-2011
    Location
    ontario, canada
    MS-Off Ver
    Excel 2003
    Posts
    10

    Re: Button to display a formula result in a different cell

    Okay, how do I do that?
    Do you just want me to copy everything in the box and paste it here?

  10. #10
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Button to display a formula result in a different cell

    Hello boogeyman,

    Here is how to attach a file...

    To Attach a File:
    1. Scroll down to the window below your post Additional Options
    2. In the frame Attach Files you will see the button Manage Attachments
    3. Click the button.
    4. A new window will open titled Manage Attachments - Excel Forum.
    5. Click the Browse... button to locate your file for uploading.
    6. This will open a new window File Upload.
    7. Once you have located the file to upload click the Open button. This window will close.
    8. You are now back in the Manage Attachments - Excel Forum window.
    9. Click the Upload button and wait until the file has uploaded.
    10. Close the window and then click Submit.

  11. #11
    Registered User
    Join Date
    01-23-2011
    Location
    ontario, canada
    MS-Off Ver
    Excel 2003
    Posts
    10

    Re: Button to display a formula result in a different cell

    Please Login or Register  to view this content.

  12. #12
    Registered User
    Join Date
    01-23-2011
    Location
    ontario, canada
    MS-Off Ver
    Excel 2003
    Posts
    10

    Re: Button to display a formula result in a different cell

    Is there any way for me to just email you my worksheet?
    I'd rather not post it where anyone can see it.
    It's for my business and it's going to be my differentiator among my competitors.
    If not, that's okay, I'll keep playing around with it.

  13. #13
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Button to display a formula result in a different cell

    Hello boogeyman,

    You can email the workbook to [email protected]. However, I will post the code that solves the problem without any data that is confidential or sensitive.

  14. #14
    Registered User
    Join Date
    01-23-2011
    Location
    ontario, canada
    MS-Off Ver
    Excel 2003
    Posts
    10

    Re: Button to display a formula result in a different cell

    I just sent it Leith.

  15. #15
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Button to display a formula result in a different cell

    Hello boogeyman,

    I received the workbook and am examining it.

  16. #16
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Button to display a formula result in a different cell

    Hello boogeyman,

    I am emailing the updated workbook to you. Here are the changes that were made.
    The code below has been removed from the "Combination" worksheet.

    Please Login or Register  to view this content.

    This code has been added to the ThisWorkbook module.
    Please Login or Register  to view this content.

  17. #17
    Registered User
    Join Date
    01-23-2011
    Location
    ontario, canada
    MS-Off Ver
    Excel 2003
    Posts
    10

    Re: Button to display a formula result in a different cell

    I received your email, but I don't see the latest code update anywhere.
    I still want the I14 cell to default to some text every time the workbook is opened until the user presses the button.
    Can you let me know where to paste your latest code update?

  18. #18
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Button to display a formula result in a different cell

    Hello boogeyman,

    You don't need to make any changes. I added them to the workbook I am sending you. The Workbook_Open() event should have been this...
    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)

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