I can set the property of a cell using the interior object fine, as long as as the procedure is called from a Sub - command button or whatever. The problem is, I want a row to be coloured when a user makes an alteration to a cell - and the Interior object *WONT* color the cell if called from within a function or a sub embedded in the function. What I want to do is this:
When I call a function, it colors the entire row - e.g, in Excel cell I put =MyCellColouringFunc(Boolvalue) - The function is now called, and if Boolvalue evaluates true the entire row is coloured 80's Neon Yellow. The value returned to the cell will be Boolvalue - e.g. Cell contents will be True or False, and the entire row will be yellow.
I don't want the user to have to click a button to update the colors in all the records if that can be avoided.
Current Code:
Function MyCellColouringFunc(Boolvalue As String) As String
If Boolvalue = "True" Then
#work out current row, then
For x = 1 To 13 'I have 13 colums I want to shade
ActiveSheet.Cell(currentrow, x).Interior.ColorIndex = 23
ActiveSheet.Cell(currentrow, x).Interior.Pattern = xlSolid
Next x
End If
MyCellColouringFunc = Boolvalue
End Function
One final note, I've tried using 'Range' instead of Cell, and defining the sheet instead of using ActiveSheet - Now, I'm pretty new to VB, so I may be missing something fundemental (like u can't call scripts from functions or something) - But *ANY* help is appericated, the more detailed the better![Wink ;) ;)](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)
Many Thanks
Joseph
When I call a function, it colors the entire row - e.g, in Excel cell I put =MyCellColouringFunc(Boolvalue) - The function is now called, and if Boolvalue evaluates true the entire row is coloured 80's Neon Yellow. The value returned to the cell will be Boolvalue - e.g. Cell contents will be True or False, and the entire row will be yellow.
I don't want the user to have to click a button to update the colors in all the records if that can be avoided.
Current Code:
Function MyCellColouringFunc(Boolvalue As String) As String
If Boolvalue = "True" Then
#work out current row, then
For x = 1 To 13 'I have 13 colums I want to shade
ActiveSheet.Cell(currentrow, x).Interior.ColorIndex = 23
ActiveSheet.Cell(currentrow, x).Interior.Pattern = xlSolid
Next x
End If
MyCellColouringFunc = Boolvalue
End Function
One final note, I've tried using 'Range' instead of Cell, and defining the sheet instead of using ActiveSheet - Now, I'm pretty new to VB, so I may be missing something fundemental (like u can't call scripts from functions or something) - But *ANY* help is appericated, the more detailed the better
Many Thanks
Joseph