Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
There is probably a real simple way to solve this but I am just now learning
VBA for Excel. Given the Sub Worksheet_Change I can work on the range(myproject) in one of the macros. Why can't I pass a single cell to another common macro to change the colors? I'd like to do this to avoid repeating the same commands for each myProject Private Sub Worksheet_Change(ByVal Target As Excel.Range) If Target.Column = 2 Then Set myProject = Range("rProject1") Project1 (myProject) ElseIf Target.Column = 3 Then Set myProject = Range("rProject2") Project2 (myProject) '<<Repeats for 10 projects End If End Sub Sub Project1(myProject) 'Search through Project 1 and see if enough roles have been performed to complete the project myval = 0 For Each c In myProject If c "" Then myval = myval + 1 End If Next c Set colorcell = Range("Pnum1") If myval = 3 Then ColormeGreen (colorcell) Else If myval 3 Then ColormeOrange (colorcell) Else 'This works, the two above do not. Pnum1 is defined on the worksheet as cell B2 With Range("B2") .Font.ColorIndex = 1 .Interior.ColorIndex = 0 End With End If End If End Sub Sub ColormeGreen(colorcell) For Each c In colorcell .Font.ColorIndex = 3 .Interior.ColorIndex = 4 .Interior.Pattern = xlSolid Next c End Sub |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Pass IE web address to Excel | Excel Programming | |||
Pass Cell Address to OFFSET | Excel Worksheet Functions | |||
Can I modify cell attributes (font,color etc.) based on function . | Excel Discussion (Misc queries) | |||
How to pass interior colours of specified range to a control. | Excel Programming | |||
VBA syntax for Font & Interior ColorIndex | Excel Discussion (Misc queries) |