Catcher in the Rye

M

moneyball.wilson

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
 
A

ADK

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 said:
What about conditional formatting?

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
 
M

moneyball.wilson

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




What about conditional formatting?
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.
 
G

Guest

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...

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




What about conditional formatting?
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top