View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
quietlee2021 quietlee2021 is offline
external usenet poster
 
Posts: 1
Default Catcher in the Rye

Try this in a spreadsheet - keep column A open, add your values of Red,
Green, Blue, Purple to column B - insert a new code module and then paste
this in:

Sub ColorMyWorld()
Dim sRange As String
Dim sACol As String, sBCol As String
Dim i As Integer
Dim sCell As String

sBCol = "B"
sACol = "A"

For i = 1 To 4
sRange = sBCol & i
Range(sRange).Select
sCell = Range(sRange).Value
Select Case sCell
Case "Red"
Range(sACol & i).Value = "A4"
Case "Green"
Range(sACol & i).Value = "A3"
Case "Blue"
Range(sACol & i).Value = "A2"
Case "Purple"
Range(sACol & i).Value = "A1"
End Select
Next
End Sub

This should get you started - you of course need to add a routine that would
figure out the last row for the For Next statement...

" wrote:

On Jul 31, 12:39 pm, "ADK" wrote:
Conditional Formatting:http://www.cpearson.com/excel/cformatting.htm

Conditional in Code (more than 3 conditions):http://www.vbaexpress.com/kb/getarticle.php?kb_id=90

"ADK" wrote in message

...



What about conditional formatting?


wrote in message
oups.com...
Hello,


I am new at programming in excel and thought I might turn here for
some help.


I am trying to code a macro to help me with a problem that I have.


My worksheet looks like this


[Condition Code] [ Condition]
Red
Green
Blue
Purple


I am trying to write some code in visual basic that says "If the cell
in condition column equals a given color (i.e. Red) then place the
condition code (i.e A4) in the condition code column.


I have many records so scrolling through and entering manually will
take much time.


Can anyone provide assitance? Please let me know if I can be more
specific.


Sincerely,
Rambo- Hide quoted text -


- Show quoted text -


Thank you very much for the suggestion, but as far as I can tell
conditional formatting will not allow me to add a value to a different
column only change the formatting of the column.