+ Reply to Thread
Results 1 to 17 of 17

Help changing color of cells on button click

  1. #1
    Registered User
    Join Date
    08-26-2016
    Location
    england
    MS-Off Ver
    ms office
    Posts
    26

    Help changing color of cells on button click

    Hi,

    I am having problems changing the cell color on button click.

    I want the cells to be invisible/white when the file opens but when i click a button for the cell to change color.

    Please see code below


    Please Login or Register  to view this content.
    It is giving me a

    run time error 1004

    Application-Defined or object-defined error

    Any ideas or help much appreciated.

    Thanks in advance
    Attached Files Attached Files
    Last edited by LePig; 08-26-2016 at 09:32 AM.

  2. #2
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Help changing color of cells on button click

    Sounds like one of the sheets might not exist? Verify the exact name of Quotation Form and Sheet21, including any leading or trailing spaces? Otherwise maybe attach the workbook.

    Please refer to forum rule #3 regarding code tags when posting code.
    Please help by:

    Marking threads as closed once your issue is resolved. How? The Thread Tools at the top
    Any reputation (*) points appreciated. Not just by me, but by all those helping, so if you found someone's input useful, please take a second to click the * at the bottom left to let them know

    There are 10 kinds of people in this world... those who understand binary, and those who don't.

  3. #3
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    15,602

    Re: Help changing color of cells on button click

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here



    (This thread should receive no further responses until this moderation request is fulfilled, as per Forum Rule 7)

  4. #4
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,820

    Re: Help changing color of cells on button click

    You are using "interior.colorindex" which refers to the background color of the cell not the color of the font. To make the text white(invisible), you need to use something like this:
    Please Login or Register  to view this content.
    You can say "THANK YOU" for help received by clicking the Star symbol at the bottom left of the helper's post.
    Practice makes perfect. I'm very far from perfect so I'm still practising.

  5. #5
    Registered User
    Join Date
    08-26-2016
    Location
    england
    MS-Off Ver
    ms office
    Posts
    26

    Re: Help changing color of cells on button click

    Apologies for not conforming with code tags.

    The sheet exists because it recognises the first argument and will put out the msgbox - i can make the code work in a new file it will not work in my original file that contains lots of other code.

    For some reason yesterday in my project explorer my sheet jumped to sheet21 and a new blank sheet went in at sheet2, i want to delete it so i can rename quotation form as sheet2.

    Do you know how or if i can delete a sheet out of the project explorer - as the sheet does not exist in my workbook?

    Thanks in advance

  6. #6
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    15,602

    Re: Help changing color of cells on button click

    Please go in the first post and edit as described.

  7. #7
    Registered User
    Join Date
    08-26-2016
    Location
    england
    MS-Off Ver
    ms office
    Posts
    26

    Re: Help changing color of cells on button click

    apologies all done

  8. #8
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    15,602

    Re: Help changing color of cells on button click

    Thank you. Hope you'll get your answer soon.

  9. #9
    Registered User
    Join Date
    08-26-2016
    Location
    england
    MS-Off Ver
    ms office
    Posts
    26

    Re: Help changing color of cells on button click

    How do i attached the file?

  10. #10
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    15,602

    Re: Help changing color of cells on button click

    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window.

    remember to overwrite all private informations.

  11. #11
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Help changing color of cells on button click

    I'm assuming when you say Sheet2 does not exist in workbook you mean it does not show on the bottom tabs? But you do see it in the project explorer? It may be hidden, or even "very hidden" which would mean it doesn't show even when you select the "unhide" option. In the project explorer is is called "Sheet2" ?
    You can just use a mini macro to delete it and then you can delete the code again.

    Please Login or Register  to view this content.

  12. #12
    Registered User
    Join Date
    08-26-2016
    Location
    england
    MS-Off Ver
    ms office
    Posts
    26

    Re: Help changing color of cells on button click

    I have attached the file now at the top - i tried your remover but it seems not to remove sheet2?

  13. #13
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Help changing color of cells on button click

    Indeed, haven't seen that before... it has no name but also different icon

    Ill get back to you.

  14. #14
    Registered User
    Join Date
    08-26-2016
    Location
    england
    MS-Off Ver
    ms office
    Posts
    26

    Re: Help changing color of cells on button click

    I think that is what is causing the problem because the code works fine in a new file

  15. #15
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Help changing color of cells on button click

    Yeah, it looks like a workbook object based on the icon, but no idea how to remove it unless it has something to do with references...
    You may just want to copy all the sheets and code to a new book.

  16. #16
    Registered User
    Join Date
    08-26-2016
    Location
    england
    MS-Off Ver
    ms office
    Posts
    26

    Re: Help changing color of cells on button click

    will that also copy all of my conditional formatting?

  17. #17
    Registered User
    Join Date
    08-26-2016
    Location
    england
    MS-Off Ver
    ms office
    Posts
    26

    Re: Help changing color of cells on button click

    will it also copy all of my conditional formatting?

+ 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. [SOLVED] Change the Color of One Command Button with Click of Another
    By Raymundus in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 01-26-2016, 03:29 PM
  2. [SOLVED] Click oval option button to fill/unfill color, also change border color to match fill
    By Rocky2013 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-07-2015, 08:29 PM
  3. Replies: 3
    Last Post: 08-18-2014, 12:47 PM
  4. [SOLVED] click on a color button and after button click it will color entire row of cell you click
    By swade730 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-11-2014, 06:06 PM
  5. VBA code for changing color of dots upon click not working as it once did
    By jenny1234 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-19-2013, 03:38 PM
  6. [SOLVED] Changing font attributes on click of button
    By stuartadair in forum Excel General
    Replies: 8
    Last Post: 06-07-2012, 07:47 AM
  7. Changing cells color without clicking command button
    By grumpyguppy in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-19-2008, 03:22 AM

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