• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

macro command botton

realtop17

New Member
hi sir,


can you please give me the step by step proces of below macro command buttom.


best regards


Sub ColorChange()

Dim OriginalColor As Integer

'You need to make a note of what the name

'of your shape/button is

ActiveSheet.Shapes("Star1").Select


'Store original color

OriginalColor = Selection.Interior.ColorIndex


'Change color to something else

Selection.Interior.ColorIndex = 5


'Do stuff here


ActiveSheet.Shapes("Star1").Select

'Change color back

Selection.Interior.ColorIndex = OriginalColor


End Sub
 
h9i sir can you please show me the step by step procedures of below sample command button.


best regards

realtop17


Sub ColorChange()

Dim OriginalColor As Integer

'You need to make a note of what the name

'of your shape/button is

ActiveSheet.Shapes("Star1").Select


'Store original color

OriginalColor = Selection.Interior.ColorIndex


'Change color to something else

Selection.Interior.ColorIndex = 5


'Do stuff here


ActiveSheet.Shapes("Star1").Select

'Change color back

Selection.Interior.ColorIndex = OriginalColor


End Sub
 
Hi, realtop17!


I think you got the code from here:

http://chandoo.org/forums/topic/macro-to-change-shape-colour


I don't fully understand what do you want to mean with showing you step by step procedure. If it's about how to incorporate that code to an existing workbook try this:

a) open the workbook in Excel

b) make sure it has extension.xls (97-2003) or .xlsm or .xlsb (2007-2010); if not, save it as .xlsm to allow macros if you have one of the last two versiones

c) press Alt-F11 to go to the VBA editor

d) Insert, Module

e) copy the code from previous topic

f) paste it within the top right (bigger) pane in the VBA window

g) insert the following line as first in the module:

Option Explicit

h) make sure you change "Star1" to the name of your shape

i) right button on the shape and assign macro "ColorChange"


Hope it helped. If not enough, consider uploading the file (Give a look at the second green sticky post at this forums main page for uploading guidelines).


Regards!
 
Back
Top