Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 53
Default Accessing a variable(a range) and modifying it

I have written the macro as below

Function FindOldNominal(NomCode, Range)

FindOldNominal = WorksheetFunction.VLookup(NomCode, Range,5,false)
End Function


My question is what code can I insert that will change the colour (say) of
the cell accessed by this function.
My aim is to show all the cells accessed (and contents returned) by changing
their colour so I know which cells in my table have not yet been looked at.

Thanks
James



"TOM REPLIED THE FOLLOWING"
Nothing.

from this context, A function can do nothing more than returning a value to
the cell in which it is located - just like the built in functions.

You could possibly have each function update a defined name or public
variable or something and then use the calculate event to access that list
and color the cells.

--
Regards,
Tom Ogilvy


SO IF I HAVE A DEFINED RANGE "NAME" SAY, WHAT CODE DO I NEED IN THE FUNCTION
TO ACCESS AND UPDATE A CELL IN THE RANGE (i'd like to change the colour of
any accessed cells to red, which were found in the lookup)
Many thank James


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Accessing a variable(a range) and modifying it

without knowing what you are trying to achieve:

In a general module:

Public v(1 To 65536) As String
Public idex As Integer


Function FindOldNominal(NomCode, Rng1 As Range)
Dim Rng As Range, s As String
Dim bFnd As Boolean
Set Rng = Application.Caller
s = Rng.Address(0, 0, xlA1, True)
bFnd = False
If idex 0 Then
For i = 1 To 65536
If v(i) = s Then
bFnd = True
Exit For
ElseIf IsEmpty(v(i)) Then
Exit For
End If
Next
If Not bFnd Then
idex = idex + 1
v(idex) = s
End If
Else
idex = idex + 1
v(idex) = s
End If

FindOldNominal = WorksheetFunction.VLookup(NomCode, Range,5,false)
End Function

In the worksheet module:

Private Sub Worksheet_Calculate()
For i = 1 To idex
If Len(Trim(v(i))) 0 Then _
Evaluate(v(i)).Interior.ColorIndex = 3
Next
End Sub

--
Regards,
Tom Ogilvy



"James Cornthwaite" wrote:

I have written the macro as below

Function FindOldNominal(NomCode, Range)

FindOldNominal = WorksheetFunction.VLookup(NomCode, Range,5,false)
End Function


My question is what code can I insert that will change the colour (say) of
the cell accessed by this function.
My aim is to show all the cells accessed (and contents returned) by changing
their colour so I know which cells in my table have not yet been looked at.

Thanks
James



"TOM REPLIED THE FOLLOWING"
Nothing.

from this context, A function can do nothing more than returning a value to
the cell in which it is located - just like the built in functions.

You could possibly have each function update a defined name or public
variable or something and then use the calculate event to access that list
and color the cells.

--
Regards,
Tom Ogilvy


SO IF I HAVE A DEFINED RANGE "NAME" SAY, WHAT CODE DO I NEED IN THE FUNCTION
TO ACCESS AND UPDATE A CELL IN THE RANGE (i'd like to change the colour of
any accessed cells to red, which were found in the lookup)
Many thank James



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
Modifying the Range Nameange the names Arun Excel Discussion (Misc queries) 4 December 11th 07 04:01 PM
Accessing specific items in a range droopy928gt Excel Programming 3 January 8th 06 06:48 PM
setting a range variable equal to the value of a string variable Pilgrim Excel Programming 2 July 1st 04 11:32 PM
VLookup error message while accessing range in closed workbook. Peter McNaughton Excel Programming 1 September 10th 03 06:11 AM
Accessing/Clearing range in hidden workbook DarrenW Excel Programming 2 July 17th 03 04:00 AM


All times are GMT +1. The time now is 09:26 AM.

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"