How to fill color in a particular Excel cell ??
Hi!
I just wanted to know how to color a particular cell in an excel worksheet. I guess it wont be that difficult but dun know the command to do this.. Please Help
cheers
Abhilash
PS: I also wanted to know how to use checkboxes in a windows form. I would be thankful if anyone can help me out..
Re: How to fill color in a particular Excel cell ??
Hi Abhi
Lets say you want to color the cell E6 Red then follow the below code :)
vb Code:
Range("E6").Select
With Selection.Interior
.ColorIndex = 3
.Pattern = xlSolid
End With
Remember, whenever in doubt, simply record a macro ;)
Also check out the FAQ's on How to record a Macro. I believe Rob has it covered in the FAQ's
Regd Checkboxes, what exactly do you want to do?
ps: You can add checkboxes in the design mode and then double click on the control to get to the code area to type in the code.
Hope this helps...
Re: How to fill color in a particular Excel cell ??
hi..
thx for the help.. wanted to ask.. can i run a macro through a vb code..
oh.. so the method for checkboxes and buttons are the same is it..??
cheers
Abhilash
Re: How to fill color in a particular Excel cell ??
Essentially your macro is VB code, so there's no issue there - just call it as a separate function from your VB code.
Did you want to add checkboxes etc in Excel or Access? :confused:
~ James
Re: How to fill color in a particular Excel cell ??
oh ok.. thx james..
i wan to add checkboxes in a normal windows form.. but i am writing a code which performs functions on excel depending on which checkboxes are checked..
precisely, the only difference will be in the column name which is worked on depending on which box is checked..
cheers
Abhilash
Re: How to fill color in a particular Excel cell ??
Incidentally, did you know that there is a property called LinkedCell for objects in the main Excel sheet, and ControlSource for those on a UserForm, which link the value of a checkbox (etc) to an Excel cell, so that changes in the box can be referred directly into the sheet and vice versa. You could therefore use conditional formatting - if the value of a particular cell is TRUE then set a certain colour and if FALSE then set another. All this accomplished without any need for code.
zaza
Re: How to fill color in a particular Excel cell ??
Hey thx zaza..
I'll try to find out more on this..
cheers
Abhilash