LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Pass a cell address - Modify interior font

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
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
Pass IE web address to Excel grove Excel Programming 2 April 10th 08 01:05 PM
Pass Cell Address to OFFSET ExcelGuy555 Excel Worksheet Functions 3 August 18th 07 07:42 AM
Can I modify cell attributes (font,color etc.) based on function . TicklePig Excel Discussion (Misc queries) 4 December 4th 05 04:23 AM
How to pass interior colours of specified range to a control. ExcelMonkey Excel Programming 5 July 27th 05 12:53 PM
VBA syntax for Font & Interior ColorIndex Dennis Excel Discussion (Misc queries) 1 November 25th 04 07:38 PM


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

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

About Us

"It's about Microsoft Excel"