+ Reply to Thread
Results 1 to 6 of 6

Message box

  1. #1
    Registered User
    Join Date
    03-20-2010
    Location
    Lincolnshire
    MS-Off Ver
    Excel 2003
    Posts
    3

    Message box

    Hi
    I am trying to get a MsgBox to pop up when I click on a command button to show the result of a Macro with the formula =Sum(A1*B1) . In Basic terms I have created a macro that multiplys A1:B1 and shows the result in a cell, I want the MsgBox to show the result.
    Can this be done
    Regards
    Planner

    P.S If Not can someone suggest a method to achieve something similiar

  2. #2
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,375

    Re: Message box

    Hi planner,

    welcome to the forum. What is the code that you have so far? If you have a variable that stores your calculation, you can use something like

    Please Login or Register  to view this content.

  3. #3
    Forum Expert Palmetto's Avatar
    Join Date
    04-04-2007
    Location
    South Eastern, USA
    MS-Off Ver
    XP, 2007, 2010
    Posts
    3,978

    Re: Message box

    formula =Sum(A1*B1)
    You don't need the SUM function. Just use = A1*B1

    In Basic terms I have created a macro that multiplys A1:B1 and shows the result in a cell, I want the MsgBox to show the result.
    It's not clear if you are calculating within the macro, have a formula already in a cell or you are placing a formula into the cell via VBA.

    However, this may be of help.
    Calculate the product inside the code
    Please Login or Register  to view this content.
    Reference values in cells A1:B1, write the result to C1, then display the value in a message box.
    Please Login or Register  to view this content.
    Palmetto

    Do you know . . . ?

    You can leave feedback and add to the reputation of all who contributed a helpful response to your solution by clicking the star icon located at the left in one of their post in this thread.

  4. #4
    Registered User
    Join Date
    03-20-2010
    Location
    Lincolnshire
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: Message box

    Hi teylyn and Palmetto
    Thanks for your quick replys, and both of you gave me the solution, but I also need to add a message in side the MsgBox along with the sum total of A1*B1 as per my first post. eg: the answer is + the sum of A1*B1. This is the code I have at the moment

    Please Login or Register  to view this content.
    Regards
    Planner
    Last edited by teylyn; 03-21-2010 at 07:56 PM. Reason: added code tags

  5. #5
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,375

    Re: Message box

    Planner, please wrap your code in code tags, as Palmetto and I did in our posts. The forum rules explain how. I will do it for you this time, but I expect you to use code tags from now on.

    As to the code you want: If you want the message box to show the value of the calculation in cell C1, then you need to call a message box after you've performed the calculation, not before. You can concatenate the text that the messagebox displays with the text concatenation character, the ampersand sign.

    There is no need to select the cell to populate it with a formula. Something like this:

    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    03-20-2010
    Location
    Lincolnshire
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: Message box

    Thankyou, and I will wrap my code in tags in future.
    Planner

+ 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