[SOLVED] Commandbutton Backcolor vs ColorIndex - Page 2


"Excel VBA Help"

 


Play Friv Now - Play Friv Games
Go Back   The Code Cage Forums > Microsoft Topics > Microsoft Excel Forum
Our Info Pages:-
The Code Cage - Microsoft Office help

Notices

Microsoft Excel Forum Members Post questions in this forum if they are related to using Microsoft Excel, this includes Worksheet Functions, Excel VBA Programming, Simple Macro Code & Charting, Excel formula etc.

New Reply
 
Thread Tools Rate Thread Display Modes
  #11  
Old 6th June 2014, 06:36
GTO's Avatar
GTO GTO is offline
Forum VIP
MS Office Version: MS Office 2000 / 2010
MS Office Skill Level: code skills: PC rarely catches fire...
 
Join Date: Jan 2011
Location: Phoenix, Arizona
Posts: 88
Posts Per Day: 0.04
My Top Tip Count: 0
Thanks to others: 3
Thanked 15 Times in 15 Posts
Reputation: 265 (9) GTO is a jewel in the roughGTO is a jewel in the roughGTO is a jewel in the rough
USA
Default Re: Commandbutton Backcolor vs ColorIndex


------ Register to get rid of these "In Post" ads! ------


Hi Hennie,

Leith is asking if you could post a sample workbook with the userform and what all is to be accomplished. As the saying goes, "a picture is worth a thousand words", and generally an attached wb is worth at least that. It makes it much easier for an 'helper' to help, and of course saves any/all helpers time in each creating their own samples, whilst they guess at what you have.

Mark

The Code Cage Advertisment
Advertisement
  #12  
Old 6th June 2014, 07:57
Leith Ross's Avatar
Leith Ross Leith Ross is offline
The Code Cage Staff
Solution Centre Professional
MS Office Version: 2000, 2003 & 2010
MS Office Skill Level: Expert in VBA
 
Join Date: Dec 2008
Location: San Bruno, CA USA
Age: 59
Posts: 469
Posts Per Day: 0.15
My Top Tip Count: 0
Thanks to others: 4
Thanked 53 Times in 51 Posts
Reputation: 997 (22) Leith Ross is a splendid one to beholdLeith Ross is a splendid one to beholdLeith Ross is a splendid one to beholdLeith Ross is a splendid one to beholdLeith Ross is a splendid one to beholdLeith Ross is a splendid one to beholdLeith Ross is a splendid one to beholdLeith Ross is a splendid one to behold
USA
Default Re: Commandbutton Backcolor vs ColorIndex

------ Register to get rid of these "In Post" ads! ------


Hello Hennie,

Mark is correct about what I was asking and why. In response to your post, you have the code to color the Command Buttons as you choose. Are you having trouble making either Mark's or my macro work correctly?
__________________
Sincerely,
Leith Ross

Microsoft Office Help

The Code Cage Advertisment
Advertisement
  #13  
Old 6th June 2014, 08:32
Hennie Neuhoff's Avatar
Hennie Neuhoff Hennie Neuhoff is offline
Junior Member
MS Office Version: Ms Office 2010
MS Office Skill Level: Proficient with Excel
 
Join Date: Jun 2009
Location: South Africa
Age: 65
Posts: 116
Posts Per Day: 0.04
My Top Tip Count: 0
Thanks to others: 69
Thanked 1 Time in 1 Post
Reputation: 15 (10) Hennie Neuhoff is on a distinguished road
South_Africa
Default Re: Commandbutton Backcolor vs ColorIndex

------ Register to get rid of these "In Post" ads! ------


Hi Leith,
Test file 'in progress" attached
Attached Files To view attachments in this forum your post count must be 2 or greater. You currently have 0 posts.

  #14  
Old 6th June 2014, 14:47
snb's Avatar
snb snb is offline
Forum VIP
MS Office Version: > Office 97
MS Office Skill Level: Interested
 
Join Date: Feb 2011
Location: Europe
Posts: 1,393
Posts Per Day: 0.57
My Top Tip Count: 0
Thanks to others: 0
Thanked 314 Times in 307 Posts
Reputation: 5076 (70) snb has a reputation beyond reputesnb has a reputation beyond reputesnb has a reputation beyond reputesnb has a reputation beyond reputesnb has a reputation beyond reputesnb has a reputation beyond reputesnb has a reputation beyond reputesnb has a reputation beyond reputesnb has a reputation beyond reputesnb has a reputation beyond reputesnb has a reputation beyond repute
Default Re: Commandbutton Backcolor vs ColorIndex

------ Register to get rid of these "In Post" ads! ------


This suffices:

VBA CODE:
Private Sub UserForm_Initialize() 
    For j = 1 To 50 
        Cells(1, 10).Interior.ColorIndex = j 
        Me("Combut" & j).BackColor = Cells(1, 10).Interior.Color 
    Next 
End Sub 

and later:


VBA CODE:
Private Sub ComBut1_Click() 
    M_toon 1 
End Sub 
Private Sub ComBut2_Click() 
    M_toon 2 
End Sub 
Private Sub ComBut3_Click() 
    M_toon 3 
End Sub 
Private Sub ComBut4_Click() 
    M_toon 4 
End Sub 
Private Sub ComBut5_Click() 
    M_toon 5 
End Sub 
Private Sub ComBut6_Click() 
    M_toon 6 
End Sub 
 
Sub M_toon(y) 
    TBox1.Text = 1 
    TBox2.BackColor = Me("ComBut" & y).BackColor 
End Sub 

------------------------------ posted after 4 Hours 47 minutes of original post ------------------------------

You can do with much less code.
Attached Files To view attachments in this forum your post count must be 2 or greater. You currently have 0 posts.


Last edited by snb; 6th June 2014 at 14:47.
Reply & Quote Reply


1 members found this post helpful.
The Following User Says Thank You to snb For This Useful Post:
Hennie Neuhoff (6th June 2014)
  #15  
Old 6th June 2014, 20:23
Leith Ross's Avatar
Leith Ross Leith Ross is offline
The Code Cage Staff
Solution Centre Professional
MS Office Version: 2000, 2003 & 2010
MS Office Skill Level: Expert in VBA
 
Join Date: Dec 2008
Location: San Bruno, CA USA
Age: 59
Posts: 469
Posts Per Day: 0.15
My Top Tip Count: 0
Thanks to others: 4
Thanked 53 Times in 51 Posts
Reputation: 997 (22) Leith Ross is a splendid one to beholdLeith Ross is a splendid one to beholdLeith Ross is a splendid one to beholdLeith Ross is a splendid one to beholdLeith Ross is a splendid one to beholdLeith Ross is a splendid one to beholdLeith Ross is a splendid one to beholdLeith Ross is a splendid one to behold
USA
Default Re: Commandbutton Backcolor vs ColorIndex

------ Register to get rid of these "In Post" ads! ------


Hello Hennie Neuhoff,

I made some changes to your test workbook. The color command buttons now execute the same code without having to write the code into each command button's click event. When the user clicks the color command button, TBox1 one will show the color index number and TBox2 will have it's backcolor set the same as the command button.
Attached Files To view attachments in this forum your post count must be 2 or greater. You currently have 0 posts.
__________________
Sincerely,
Leith Ross

Microsoft Office Help

Reply & Quote Reply


1 members found this post helpful.
The Following User Says Thank You to Leith Ross For This Useful Post:
Hennie Neuhoff (8th June 2014)
The Code Cage Advertisment
Advertisement
  #16  
Old 6th June 2014, 20:40
snb's Avatar
snb snb is offline
Forum VIP
MS Office Version: > Office 97
MS Office Skill Level: Interested
 
Join Date: Feb 2011
Location: Europe
Posts: 1,393
Posts Per Day: 0.57
My Top Tip Count: 0
Thanks to others: 0
Thanked 314 Times in 307 Posts
Reputation: 5076 (70) snb has a reputation beyond reputesnb has a reputation beyond reputesnb has a reputation beyond reputesnb has a reputation beyond reputesnb has a reputation beyond reputesnb has a reputation beyond reputesnb has a reputation beyond reputesnb has a reputation beyond reputesnb has a reputation beyond reputesnb has a reputation beyond reputesnb has a reputation beyond repute
Default Re: Commandbutton Backcolor vs ColorIndex

------ Register to get rid of these "In Post" ads! ------


You both might have a look in:

http://www.thecodecage.com/forumz/at...6&d=1402062436

Reply & Quote Reply


1 members found this post helpful.
The Following User Says Thank You to snb For This Useful Post:
Hennie Neuhoff (7th June 2014)
The Code Cage Advertisment
Advertisement

To stop seeing these ads and get other benefits check This page!

New Reply
The Code Cage at Facebookhe Code Cage at Twitter


Tags
backcolor, colorindex, commandbutton

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

The Code Cage Affilliates



http://www.thecodecage.com/forumz tested by McAfee Security http://www.thecodecage.com/forumz tested by McAfee Security

All times are GMT +1. The time now is 11:22.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Template-Modifications by TMS
No part of this board, functionality or creatives may be copied or reproduced either in part or full without the express permission of The Code Cage Team.
Copyright ©2008 - , Simon lloyd.
We are not associated with nor employed by Microsoft in any way, we simply provide resources!
All MS office icons are registered trademarks of the application they represent and are used with permission from Microsoft
UA-8135493-1
Cultural Forum | Study at Malaysian University
X vBulletin 3.8.7 Debug Information
  • Page Generation 0.20918 seconds
  • Memory Usage 6,540KB
  • Queries Executed 15 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footerEnd
  • (1)ad_footerStart
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_headerEnd
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_leftcolumn_code
  • (1)ad_navbar_below
  • (4)ad_postbit_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (2)bbcode_code
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)helpful_answers
  • (1)helpfulanswers_javascript
  • (1)navbar
  • (3)navbar_link
  • (2)navbar_noticebit
  • (41)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (6)post_thanks_box
  • (3)post_thanks_box_bit
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (3)post_thanks_postbit
  • (6)post_thanks_postbit_info
  • (6)postbit
  • (3)postbit_attachment
  • (6)postbit_ctoptip
  • (6)postbit_onlinestatus
  • (42)postbit_reputation
  • (6)postbit_wrapper
  • (1)showthread_changepostsowner_link
  • (1)showthread_quickreply_mrgdp
  • (1)showthread_reason_popup
  • (1)spacer_close
  • (1)spacer_open
  • (1)su_form
  • (3)tagbit
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_datastore.php
  • ./includes/class_hook.php
  • ./awcoding/plugins/awc.php
  • ./awcoding/plugins/ds.php
  • ./awcoding/plugins/ss.php
  • ./includes/functions_notice.php
  • ./mobiquo/smartbanner.php
  • ./mobiquo/include/classTTConnection.php
  • ./mobiquo/smartbanner/head.inc.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/vbatags.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php
  • ./includes/functions_misc.php 

Hooks Called:
  • init_startup
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • fetch_musername
  • notices_check_start
  • notices_check_criteria
  • notices_noticebit
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • helpfulanswers_showthreadorpost
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • helpfulanswers_show_normal
  • reputation_power
  • reputation_image
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • error_fetch
  • postbit_attachment
  • post_thanks_function_fetch_thanks_bit_start
  • post_thanks_function_show_thanks_date_start
  • post_thanks_function_fetch_thanks_bit_end
  • post_thanks_function_fetch_post_thanks_template_start
  • post_thanks_function_fetch_post_thanks_template_end
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete