Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

altering the interior color of a selection of cells with a commandbutt

Status
Not open for further replies.

funkmonsteruk

IS-IT--Management
Feb 8, 2002
210
GB
I have a diary system which allows users to select a range of cells (representing date/time) and change the colour of those cells. I am currently in the process of updating the diary system and replacing macro buttons with command buttons. However, i cannot get this function to work, i have tried the following which works if i select some cells and step through the code but if i try and activate it from the commandbutton it gives my an 'unable to set interior color class' error

Private sub commandbutton1_click()

with selection.interior
.colorindex = 40
.pattern = xlsolid
end with

End sub

Any suggestions..................
 
funkmonsteruk,

Have you tried splitting it out of the with?

e.g.
activecell.interior.colorindex = 40
activecell.interior.pattern = xlsolid

does it still error?

If it does then it the way your accessing the cells.
Do you need the with? at the end of the day youve saved 2 lines in my e.g.


[pc3]
Adam [glasses]
 
I have had this problem too.

Set the TakeFocusOnClick property for commandbutton1= false

Try to run from the button again.




 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top