Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 31
Default Another Command button doubt...

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
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Another Command button doubt...

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
  #3   Report Post  
Posted to microsoft.public.excel.misc
bj bj is offline
external usenet poster
 
Posts: 1,397
Default Another Command button doubt...

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

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 31
Default Another Command button doubt...

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
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Command Button inspirz Excel Discussion (Misc queries) 1 March 29th 07 06:38 PM
command button wayno Excel Worksheet Functions 1 July 31st 06 02:02 AM
Command Button Steved Excel Worksheet Functions 2 February 19th 06 11:01 PM
command button Hellboy Excel Discussion (Misc queries) 0 November 3rd 05 02:51 PM
command button abfabrob Excel Discussion (Misc queries) 5 October 7th 05 12:54 AM


All times are GMT +1. The time now is 01:51 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"