ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Extend a macro rule for setting color and specific text (https://www.excelbanter.com/excel-programming/450728-extend-macro-rule-setting-color-specific-text.html)

[email protected]

Extend a macro rule for setting color and specific text
 
Hello,

I'm using a macro for setting a field color based on a specific text in the same cell.

Part of the Macro:
If cell.Value Like "*XXX*" Then cell.Interior.ColorIndex = 24

Question:
I want to extend my macro to check also a text which is in the same row but 2 columns before. (So the macro should be: Active cell.value like "*XXX*" and 2 columns to left cell.value "YYY" Then.......).

For another part I also want to set a specific text in the same row 2 columns to the right. (So the macro should be: Then cell.Interior.ColorIndex = 24 and 2 columns to the right set cell value "ZZZ").

Can please somebody help me out.

regards and thanks !
Johan


Claus Busch

Extend a macro rule for setting color and specific text
 
Hi Johan,

Am Mon, 23 Mar 2015 05:10:57 -0700 (PDT) schrieb :

I want to extend my macro to check also a text which is in the same row but 2 columns before. (So the macro should be: Active cell.value like "*XXX*" and 2 columns to left cell.value "YYY" Then.......).

For another part I also want to set a specific text in the same row 2 columns to the right. (So the macro should be: Then cell.Interior.ColorIndex = 24 and 2 columns to the right set cell value "ZZZ").


try:

If rngC = "XXX" And rngC.Offset(, -2) = "YYY" Then
rngC.Interior.ColorIndex = 24
rngC.Offset(, 2) = "ZZZ"
Else
rngC.Interior.ColorIndex = xlNone
rngC.Offset(, 2) = ""
End If


Regards
Claus B.
--
Vista Ultimate / Windows7
Office 2007 Ultimate / 2010 Professional


All times are GMT +1. The time now is 11:33 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com