Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Automating the rest of this....

I am new to Visual Basic programming in Excel. I am attempting to
program something that takes two numerical values out of Excel and
applies a color label such as "RED" or "YELLOW" above them depending
on their individual values. Then, a private sub-routine looks for
those word labels (like "RED) and colors them the appropriate color
automatically. The last thing I need to do is automate the word label
routine so that when I put a number in a cell and another number in
the cell right below it it applies the color label above those two
numbers. Any suggestions?

Thanks,
MZ


Example of format:
--------
|YELLOW|
--------
|2 |
--------
|2 |
--------


Here are some samples of my code:

Sub Worksheet_Change1()

'Define two variables
Dim LL As Integer
Dim ML As Integer

' begin error trapping.
On Error GoTo Done

' Start for loops to search through cells for numerical values
For i = 1 To 250
For j = 1 To 100

'take in a value at the ith and jth position
ML = Cells(i, j).Value
'take the value below the ith and jth cell
LL = Cells(i + 1, j).Value

'as long as ML is not zero start the conditional statements
If (Not ML) Then

'This is an example of how I assign color values to numerical
values, the rest of the code looks like this except for incrementing
the for loop

If (ML 0 And ML <= 5) Then

If (LL 0 And LL <= 6) Then
Cells(i - 1, j) = "GREEN"

ElseIf (LL 6 And LL <= 13) Then
Cells(i - 1, j) = "RED"

ElseIf (LL 13 And LL <= 25) Then
Cells(i - 1, j) = "YELLOW"

Else

End If
End If



Routine that automatically colors a RED, GREEN, or YELLOW label:

Private Sub Worksheet_Change(ByVal Target As Excel.Range)

'Begin looking through cells 100 accross and 250 down
For k = 1 To 250
For l = 1 To 100

'in the kth and lth cell make the target value the proper color
If ((Target.Row = k) And (Target.Column = l)) Then
If (Target.Value = "RED") Then
Target.Font.Color = vbRed
ElseIf (Target.Value = "GREEN") Then
Target.Font.Color = vbGreen
ElseIf (Target.Value = "YELLOW") Then
Target.Font.Color = vbYellow
Else
Target.Font.Color = vbDefault
End If
End If

Next l
Next k

End Sub
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
Video for rest Serolikt Excel Discussion (Misc queries) 0 October 15th 08 11:13 PM
Can you put in anything so rest of row changes colour? Sara Excel Discussion (Misc queries) 9 February 19th 08 12:21 PM
Loan Amortization with a rest value Boskantertje Excel Discussion (Misc queries) 2 September 15th 07 06:20 PM
Only see name box and formula box where is the rest? vik Excel Discussion (Misc queries) 6 January 17th 06 10:30 PM
ex.=($B$4+C4) in macros for row why adding rest Sherry Excel Worksheet Functions 4 December 30th 05 12:19 AM


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

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"