+ Reply to Thread
Results 1 to 8 of 8

Need message box code to change background color in macro

  1. #1
    Registered User
    Join Date
    11-10-2011
    Location
    Chatsworth, California
    MS-Off Ver
    Excel 2010
    Posts
    41

    Need message box code to change background color in macro

    I have a macro creating background color. I created a message box that allows the user to change the color originally prescribed in the macro. I just do not know what code to insert after the message box so the user input changes the color of the macro.

    Any references gladly accepted. I have searched extensively.

    See attached workbook. - I am using Excel 2010 with Windows XP (32bit).
    Attached Files Attached Files
    Last edited by BGiffin2004; 11-30-2011 at 09:26 PM. Reason: To make my question & workbook much simpler

  2. #2
    Registered User
    Join Date
    11-10-2011
    Location
    Chatsworth, California
    MS-Off Ver
    Excel 2010
    Posts
    41

    Re: Need message box code to change background color in macro

    Bump no response

    I greatly simplified this post!

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

    Re: Need message box code to change background color in macro

    Have you considered this way to control cell's color:
    Please Login or Register  to view this content.
    To get the return value from an Input Box, you have to assign it to a variable

    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.

  4. #4
    Registered User
    Join Date
    11-10-2011
    Location
    Chatsworth, California
    MS-Off Ver
    Excel 2010
    Posts
    41

    Re: Need message box code to change background color in macro

    I do not know all the code in your first description to control a cell’s color. I am going to research the applicable significance of “Application.Dialogs”, & “Cells (1,1)” for a better understanding now. Thanks for caring enough to send this additional learning curve.

    I understand the code in the 2nd code window. Thanks much.

    It may take me a few hours yet to absorb all this bit that you have included above..., and marked it “Solved”, or not. I am going to eat my mashed potatoes that just came out of the microwave and internet search all the details above now. Have a good evening mikerickson!

  5. #5
    Registered User
    Join Date
    11-10-2011
    Location
    Chatsworth, California
    MS-Off Ver
    Excel 2010
    Posts
    41

    Re: Need message box code to change background color in macro

    I used mikerickson code suggestion (2nd listed code suggestion in the original reply post). It worked fine…, until I tried to account for a null value if the user just hit the OK button - without entering any number. When I entered this code I get a Runtime Error 13 “Type mismatch”.

    When I look up Error 13 on the internet it sounds as if my I need to download Microsoft’s Service Pack 3. Does anyone have experience with this? – Perhaps it is something wrong with my coding after all, and there is no need for trying to locate MS Service Pack3? In other words, is there a handy work-around? Thanks.

    This is the line Excel finds a bug with:
    Please Login or Register  to view this content.
    I have attached a copy of the work book and Word Doc of the error code. I also copied and pasted the relevant code below.

    Please Login or Register  to view this content.
    Attached Files Attached Files

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

    Re: Need message box code to change background color in macro

    This would protect against user entering something silly (like "cat")

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    11-10-2011
    Location
    Chatsworth, California
    MS-Off Ver
    Excel 2010
    Posts
    41

    Re: Need message box code to change background color in macro

    Thanks again mikerickson.
    The code for handling unnacceptable entries works perfectly.
    I am going to mark this post most definitely "SOLVED".

    * I am still working on this program to SAVE the entry using "GetSaveAsFilename". The maco wants to save it as an "xlsmword" document. - But I will post this as a separate issue/post on the Excel Forum website if I am having difficulty figuring it out.

    ** (In case you were still curious though - I attached the workbook with all the GetSaveAsFilename new code in Module1/macro "SaveChanges", and a Word doc showing the warning messages and highlighted code for what I think the problems are with the code..., and therefore what I will be working on.) Again, I will post this in the Excel forum under a new post heading if I am not able to format the workbook for saving it in "xlsm" format.

    I could not attach ColorChanges(2)Test(2).xlsmword (?); so I am attaching ColorChanges(2).xlsm
    Attached Files Attached Files
    Last edited by BGiffin2004; 11-30-2011 at 09:25 PM. Reason: Trying to attach the right attachments I want.

  8. #8
    Registered User
    Join Date
    11-10-2011
    Location
    Chatsworth, California
    MS-Off Ver
    Excel 2010
    Posts
    41

    Re: Need message box code to change background color in macro

    mikerickson,
    Just wanted to let you know I got everything done and produced a beautiful program/workbook thanks to your help. It is a lot more complex than the "background color change exercise" that you originally helped me out with. (And I will not need to post for anymore help!) - I am attaching a copy for your entertainment. (Click on the black buttons at the top of the screen.) Thanks so much!
    Attached Files Attached Files

+ 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