PC Review


Reply
Thread Tools Rate Thread

Another Command button doubt...

 
 
=?Utf-8?B?eGF2aSBnYXJyaWdh?=
Guest
Posts: n/a
 
      7th Sep 2007
Hi to all!

Here you have another question about a macro...

I need to change the fill color of some cells by clicking a command button.
I've searched VB help but I haven0t found anything.

If anyone knows the correct code please write it...

Thanks to all!
--
atrep
 
Reply With Quote
 
 
 
 
Dave Peterson
Guest
Posts: n/a
 
      7th Sep 2007
Try recording a macro when you change the selected cell's fill color.

Then stop recording.

Then add a commandbutton from the control toolbar toolbox to the worksheet.

Double click on that commandbutton and you'll see where you want to move the
code.

Then delete the original recorded macro.

When you're done, you should end up with a routine that looks like:

Option Explicit
Private Sub CommandButton1_Click()
Selection.Interior.ColorIndex = 35
End Sub

The number will depend on what color you use.

xavi garriga wrote:
>
> Hi to all!
>
> Here you have another question about a macro...
>
> I need to change the fill color of some cells by clicking a command button.
> I've searched VB help but I haven0t found anything.
>
> If anyone knows the correct code please write it...
>
> Thanks to all!
> --
> atrep


--

Dave Peterson
 
Reply With Quote
 
=?Utf-8?B?Ymo=?=
Guest
Posts: n/a
 
      7th Sep 2007
the simplest way
if it is always the same cells you want changed,
record a macro changing them
it will be something like

Sub colcel()
Range("D6,F12,H7").Select
With Selection.Interior
.ColorIndex = 6
.Pattern = xlSolid
End With
End Sub

assign a button to that macro
change color index to get the color you want

if you want to select the cells then change them
try

Sub colcel1()
With Selection.Interior
.ColorIndex = 6
.Pattern = xlSolid
End With
End Sub

if you need the macro to select the cells, what is your criteria?
"xavi garriga" wrote:

> Hi to all!
>
> Here you have another question about a macro...
>
> I need to change the fill color of some cells by clicking a command button.
> I've searched VB help but I haven0t found anything.
>
> If anyone knows the correct code please write it...
>
> Thanks to all!
> --
> atrep

 
Reply With Quote
 
=?Utf-8?B?eGF2aSBnYXJyaWdh?=
Guest
Posts: n/a
 
      12th Sep 2007
Ok Many thanks!

I'll try the solutions ans tell you if they work!

--
atrep


"Dave Peterson" wrote:

> Try recording a macro when you change the selected cell's fill color.
>
> Then stop recording.
>
> Then add a commandbutton from the control toolbar toolbox to the worksheet.
>
> Double click on that commandbutton and you'll see where you want to move the
> code.
>
> Then delete the original recorded macro.
>
> When you're done, you should end up with a routine that looks like:
>
> Option Explicit
> Private Sub CommandButton1_Click()
> Selection.Interior.ColorIndex = 35
> End Sub
>
> The number will depend on what color you use.
>
> xavi garriga wrote:
> >
> > Hi to all!
> >
> > Here you have another question about a macro...
> >
> > I need to change the fill color of some cells by clicking a command button.
> > I've searched VB help but I haven0t found anything.
> >
> > If anyone knows the correct code please write it...
> >
> > Thanks to all!
> > --
> > atrep

>
> --
>
> Dave Peterson
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
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
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
print command from command button in userform causes double chart Mike Jamesson Microsoft Excel Programming 5 11th Aug 2009 03:42 AM
Deselect Command Button by Selecting another Command Button gmcnaugh Microsoft Excel Programming 3 2nd Sep 2008 05:59 PM
doubt on command prompt manoj Microsoft C# .NET 1 16th Jan 2008 02:03 PM
Command Button Pictures Taken from Command Bar Button Icons acx@centrum.cz Microsoft Access Forms 0 2nd Dec 2007 12:23 PM
Some doubt for .NET and HTML/Server button Mihir Microsoft ASP .NET 2 15th Jul 2004 03:03 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:01 AM.