PC Review


Reply
Thread Tools Rate Thread

How to change color in a funtion

 
 
=?Utf-8?B?VGlhZ28=?=
Guest
Posts: n/a
 
      24th Oct 2006
Hi All
i have a function "getposition(range)" that get the position of the 4 higher
values in that range and at finnaly sums all numbers in the range.

so in my worksheet i just have to put =getposition(range) and the cell
display the correct sum result.

my problem is, i can't color the 4 higher values, that i stored the position
in my array(position).

for for an example imagine that "position" array is with the values
("","A5",A9","A10","A15")

******************************************
Function getposition(colunas) As Integer
Dim a As Range, c As Range

position = Array("","", "", "", "", "")
.....
.....
.....
.....
calcula = total

******will color the ranges /don't work

for i=1 to 4
Range(position(i)).Select
Selection.Font.ColorIndex = 5
Selection.Font.Bold = True
next

End Function

**************************

any ideas?
i can't select the cell even color them.
Thanks in advance
 
Reply With Quote
 
 
 
 
Niek Otten
Guest
Posts: n/a
 
      24th Oct 2006
You can not change anything in a worksheet from a function. You only return a value to replace the function call.

--
Kind regards,

Niek Otten
Microsoft MVP - Excel

"Tiago" <(E-Mail Removed)> wrote in message news:EC51FC89-22D3-4A6B-819F-(E-Mail Removed)...
| Hi All
| i have a function "getposition(range)" that get the position of the 4 higher
| values in that range and at finnaly sums all numbers in the range.
|
| so in my worksheet i just have to put =getposition(range) and the cell
| display the correct sum result.
|
| my problem is, i can't color the 4 higher values, that i stored the position
| in my array(position).
|
| for for an example imagine that "position" array is with the values
| ("","A5",A9","A10","A15")
|
| ******************************************
| Function getposition(colunas) As Integer
| Dim a As Range, c As Range
|
| position = Array("","", "", "", "", "")
| ....
| ....
| ....
| ....
| calcula = total
|
| ******will color the ranges /don't work
|
| for i=1 to 4
| Range(position(i)).Select
| Selection.Font.ColorIndex = 5
| Selection.Font.Bold = True
| next
|
| End Function
|
| **************************
|
| any ideas?
| i can't select the cell even color them.
| Thanks in advance


 
Reply With Quote
 
darrenmcconachie
Guest
Posts: n/a
 
      24th Oct 2006
Could you not colour the cells using the RANK function in conditional
formatting!?

 
Reply With Quote
 
=?Utf-8?B?VGlhZ28=?=
Guest
Posts: n/a
 
      24th Oct 2006
Thanks Niek

what you advise?

i don't use any button.... there is any way to run a sub in a cell?

"Niek Otten" wrote:

> You can not change anything in a worksheet from a function. You only return a value to replace the function call.
>
> --
> Kind regards,
>
> Niek Otten
> Microsoft MVP - Excel
>
> "Tiago" <(E-Mail Removed)> wrote in message news:EC51FC89-22D3-4A6B-819F-(E-Mail Removed)...
> | Hi All
> | i have a function "getposition(range)" that get the position of the 4 higher
> | values in that range and at finnaly sums all numbers in the range.
> |
> | so in my worksheet i just have to put =getposition(range) and the cell
> | display the correct sum result.
> |
> | my problem is, i can't color the 4 higher values, that i stored the position
> | in my array(position).
> |
> | for for an example imagine that "position" array is with the values
> | ("","A5",A9","A10","A15")
> |
> | ******************************************
> | Function getposition(colunas) As Integer
> | Dim a As Range, c As Range
> |
> | position = Array("","", "", "", "", "")
> | ....
> | ....
> | ....
> | ....
> | calcula = total
> |
> | ******will color the ranges /don't work
> |
> | for i=1 to 4
> | Range(position(i)).Select
> | Selection.Font.ColorIndex = 5
> | Selection.Font.Bold = True
> | next
> |
> | End Function
> |
> | **************************
> |
> | any ideas?
> | i can't select the cell even color them.
> | Thanks in advance
>
>
>

 
Reply With Quote
 
Bob Phillips
Guest
Posts: n/a
 
      24th Oct 2006
Use conditional formatting on all the cells with a formula of

=A1>=LARGE(A1:A100,4)

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Tiago" <(E-Mail Removed)> wrote in message
news:F734445E-3458-40C2-9A0E-(E-Mail Removed)...
> Thanks Niek
>
> what you advise?
>
> i don't use any button.... there is any way to run a sub in a cell?
>
> "Niek Otten" wrote:
>
> > You can not change anything in a worksheet from a function. You only

return a value to replace the function call.
> >
> > --
> > Kind regards,
> >
> > Niek Otten
> > Microsoft MVP - Excel
> >
> > "Tiago" <(E-Mail Removed)> wrote in message

news:EC51FC89-22D3-4A6B-819F-(E-Mail Removed)...
> > | Hi All
> > | i have a function "getposition(range)" that get the position of the 4

higher
> > | values in that range and at finnaly sums all numbers in the range.
> > |
> > | so in my worksheet i just have to put =getposition(range) and the cell
> > | display the correct sum result.
> > |
> > | my problem is, i can't color the 4 higher values, that i stored the

position
> > | in my array(position).
> > |
> > | for for an example imagine that "position" array is with the values
> > | ("","A5",A9","A10","A15")
> > |
> > | ******************************************
> > | Function getposition(colunas) As Integer
> > | Dim a As Range, c As Range
> > |
> > | position = Array("","", "", "", "", "")
> > | ....
> > | ....
> > | ....
> > | ....
> > | calcula = total
> > |
> > | ******will color the ranges /don't work
> > |
> > | for i=1 to 4
> > | Range(position(i)).Select
> > | Selection.Font.ColorIndex = 5
> > | Selection.Font.Bold = True
> > | next
> > |
> > | End Function
> > |
> > | **************************
> > |
> > | any ideas?
> > | i can't select the cell even color them.
> > | Thanks in advance
> >
> >
> >



 
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
Change Color on rows, after an IF Funtion is answered Cornelia Microsoft Excel Worksheet Functions 4 30th Apr 2009 05:11 PM
change fill color of a range of cells based on color of a cell? =?Utf-8?B?RGFyTWVsTmVs?= Microsoft Excel Programming 0 2nd Mar 2006 06:35 PM
Need help in VBA Funtion for Autogenerating a Number next to the result of the Funtion FA Microsoft Access Form Coding 1 11th Jan 2006 04:25 PM
Bullet Font Color Changes When I Change Text Color--Can I Change it Back? J. Danniel Microsoft Powerpoint 2 17th Mar 2005 08:06 PM
Browse Forms Controls and change TextBox color based on cell color =?Utf-8?B?U3RlZmFuVw==?= Microsoft Excel Programming 0 21st Nov 2004 04:28 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:40 PM.