Hello,
I have been trying to put together a macro that will interrogate the contents of a cell and return a value based on the contents (using IF THEN logic). In the Visual Basic window, the code looks like:
Sub Cause1()
'
' Cause1 Macro
'
'
Range("Y2").Select
ActiveCell.FormulaR1C1 = _
"=IF(RC[10]=""Yes"", ""Red"",
IF(RC[13]=""Yes"", ""Blue"",
IF(RC[14]=""Yes"", ""Green"",
IF(RC[16]=""Yes"", ""Orange"",
IF(RC[17]=""Yes"", ""Purple"",
IF(RC[18]=""Yes"", ""Teal"",
IF(RC[19]=""Yes"", ""Pink"",
IF(RC[20]=""Yes"", ""Black"",
IF(RC[21]=""Yes"", ""Yellow"",
IF(RC[22]=""Yes"", ""Lavender"",
IF(RC[24]=""Yes"", ""White"",
IF(RC[25]=""Yes"", ""Silver"",
IF(RC[27]=""Yes"", ""Gold"",
IF(RC[28]=""Yes"", ""Brown"",
IF(RC[29]=""Yes"", ""Navy Blue"",
IF(RC[1383]=""Yes"", ""Midnight Blue"",
IF(RC[32]=""Yes"", ""Magenta"",
IF(RC[33]=""Yes"", ""Violet"",
IF(RC[34]=""Yes"", ""Turquoise"",
IF(RC[35]=""Yes"", ""Adobe"",
IF(RC[36]=""Yes"", ""Concrete"",
IF(RC[37]=""Yes"", ""Earth"",
IF(RC[38]=""Yes"", ""Mud"",
IF(RC[11]<>"""", ""Building ""&RC[11],
IF(RC[12]<>"""", ""House ""&RC[12],
IF(RC[15]<>"""", """"&RC[15],
IF(RC[23]<>"""", ""Factory ""&RC[23])))))))))))))))))))))))))))"
Range("Y3").Select
End Sub
I tried to develop this in a bullet point format as when I tried the code on the "linear" fashion it seemed to break at the line return (despite my trying _).
Hoping someone can take a look and let me know where I am off track. When I try to run the macro I receive a Compile Error: Syntax Error on line 2 (RC 13)
Thank You,
Skip
I have been trying to put together a macro that will interrogate the contents of a cell and return a value based on the contents (using IF THEN logic). In the Visual Basic window, the code looks like:
Sub Cause1()
'
' Cause1 Macro
'
'
Range("Y2").Select
ActiveCell.FormulaR1C1 = _
"=IF(RC[10]=""Yes"", ""Red"",
IF(RC[13]=""Yes"", ""Blue"",
IF(RC[14]=""Yes"", ""Green"",
IF(RC[16]=""Yes"", ""Orange"",
IF(RC[17]=""Yes"", ""Purple"",
IF(RC[18]=""Yes"", ""Teal"",
IF(RC[19]=""Yes"", ""Pink"",
IF(RC[20]=""Yes"", ""Black"",
IF(RC[21]=""Yes"", ""Yellow"",
IF(RC[22]=""Yes"", ""Lavender"",
IF(RC[24]=""Yes"", ""White"",
IF(RC[25]=""Yes"", ""Silver"",
IF(RC[27]=""Yes"", ""Gold"",
IF(RC[28]=""Yes"", ""Brown"",
IF(RC[29]=""Yes"", ""Navy Blue"",
IF(RC[1383]=""Yes"", ""Midnight Blue"",
IF(RC[32]=""Yes"", ""Magenta"",
IF(RC[33]=""Yes"", ""Violet"",
IF(RC[34]=""Yes"", ""Turquoise"",
IF(RC[35]=""Yes"", ""Adobe"",
IF(RC[36]=""Yes"", ""Concrete"",
IF(RC[37]=""Yes"", ""Earth"",
IF(RC[38]=""Yes"", ""Mud"",
IF(RC[11]<>"""", ""Building ""&RC[11],
IF(RC[12]<>"""", ""House ""&RC[12],
IF(RC[15]<>"""", """"&RC[15],
IF(RC[23]<>"""", ""Factory ""&RC[23])))))))))))))))))))))))))))"
Range("Y3").Select
End Sub
I tried to develop this in a bullet point format as when I tried the code on the "linear" fashion it seemed to break at the line return (despite my trying _).
Hoping someone can take a look and let me know where I am off track. When I try to run the macro I receive a Compile Error: Syntax Error on line 2 (RC 13)
Thank You,
Skip