Thread: Command Button
View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Command Button

Private Sub Commandbutton1_Click()
Selection.Interior.ColorIndex = 6
End sub

Private Sub Commandbutton2_Click()
Selection.Interior.ColorIndex = 3
end Sub

Make the control toolbox toolbar visible. click on the commandbarbutton and
then rubberband a rectangle on the worksheet.

Repeat for the second button.

Double click on the first button and paste in code like the above in the
resulting module (check that your button names correspond to the code
above. If not, rename the procedures to match the names of your two
buttons.

go back to the worksheet and take the sheet out of design mode (the top left
button on the control toolbox should look depressed. Click it so it isn't).

Now select some cells and click the button.

--
Regards,
Tom Ogilvy

"Hardy" wrote in message
...
I know this probably sounds very simple to most people, but i am new at

this!
I would like to create 2 command buttons in a worksheet both doing the

same
thing. I would like when each button is clicked the highlighted cells to

be
filled in a particular colour. Eg button 1 fills the highlighted cells in
yellow and the second button would fill the highlighted cells in red. Can
anyone help?