Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
CC CC is offline
external usenet poster
 
Posts: 91
Default hard time with If InStr(1, ..

With this expression the program look the first cell of 3 cell an if find
"ACT" or "DEACT" paint this 3 cells of Yelow .



If ThisWorkbook.Sheets("list").DrawingObjects("Check Box 9").Value = xlOn Then
If InStr(1, Sheets("Grid").Cells(I, L).Value, "ACT") 0 Or _
InStr(1, Sheets("Grid").Cells(I, L).Value, "DEACT") 0 Then
'interior color yellow For Alarms: WARN and ALT
Sheets("Grid").Cells(I, L).Interior.ColorIndex = 6
Sheets("Grid").Cells(I, L + 1).Interior.ColorIndex = 6
Sheets("Grid").Cells(I + 1, L).Interior.ColorIndex = 6
Sheets("Grid").Cells(I + 1, L + 1).Interior.ColorIndex = 6


But what I need is paint on yellow if he find a word "(CC)" in the third
cell

Well my question is . can I have a search or find instead of Value,
"ACT" ?


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default hard time with If InStr(1, ..

I'm not sure what you mean by third cell or three cells, since your code is coloring FOUR cells, but
you could extend your conditional like so:

If InStr(1, Sheets("Grid").Cells(I, L).Value, "ACT") 0 Or _
InStr(1, Sheets("Grid").Cells(I, L).Value, "DEACT") 0 Or _
InStr(1, Sheets("Grid").Cells(I, L+1).Value, "CC") 0 Then


That would look for CC in second column, first row. Also, you can use one line (instead of four) to
do the coloring:

Sheets("Grid").Cells(I, L).Resize(2,2).Interior.ColorIndex = 6


HTH,
Bernie
MS Excel MVP


"CC" wrote in message
...
With this expression the program look the first cell of 3 cell an if find
"ACT" or "DEACT" paint this 3 cells of Yelow .



If ThisWorkbook.Sheets("list").DrawingObjects("Check Box 9").Value = xlOn Then
If InStr(1, Sheets("Grid").Cells(I, L).Value, "ACT") 0 Or _
InStr(1, Sheets("Grid").Cells(I, L).Value, "DEACT") 0 Then
'interior color yellow For Alarms: WARN and ALT
Sheets("Grid").Cells(I, L).Interior.ColorIndex = 6
Sheets("Grid").Cells(I, L + 1).Interior.ColorIndex = 6
Sheets("Grid").Cells(I + 1, L).Interior.ColorIndex = 6
Sheets("Grid").Cells(I + 1, L + 1).Interior.ColorIndex = 6


But what I need is paint on yellow if he find a word "(CC)" in the third
cell

Well my question is . can I have a search or find instead of Value,
"ACT" ?




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default hard time with If InStr(1, ..

you can use find but you need to set lookat:

LookAt Optional Variant. Can be one of the following XlLookAt constants:
xlWhole or xlPart.

set searchrabge = sheets("Grid").range("A1:D4")
set c = searchrange.find(what:="ACT",lookin:=xlvalues,look at:=xlPart)
if not c is nothing then
'add code if found

c.Interior.ColorIndex = 6
c.offset(0,1).Interior.ColorIndex = 6
c.offset(1,0).Interior.ColorIndex = 6
c.offset(1,1).Interior.ColorIndex = 6
else
'add code if not found
end if



"CC" wrote:

With this expression the program look the first cell of 3 cell an if find
"ACT" or "DEACT" paint this 3 cells of Yelow .



If ThisWorkbook.Sheets("list").DrawingObjects("Check Box 9").Value = xlOn Then
If InStr(1, Sheets("Grid").Cells(I, L).Value, "ACT") 0 Or _
InStr(1, Sheets("Grid").Cells(I, L).Value, "DEACT") 0 Then
'interior color yellow For Alarms: WARN and ALT
Sheets("Grid").Cells(I, L).Interior.ColorIndex = 6
Sheets("Grid").Cells(I, L + 1).Interior.ColorIndex = 6
Sheets("Grid").Cells(I + 1, L).Interior.ColorIndex = 6
Sheets("Grid").Cells(I + 1, L + 1).Interior.ColorIndex = 6


But what I need is paint on yellow if he find a word "(CC)" in the third
cell

Well my question is . can I have a search or find instead of Value,
"ACT" ?


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default hard time with If InStr(1, ..

And I'd drop the code for DEACT, too--since DEACT already has ACT in it.

CC wrote:

With this expression the program look the first cell of 3 cell an if find
"ACT" or "DEACT" paint this 3 cells of Yelow .

If ThisWorkbook.Sheets("list").DrawingObjects("Check Box 9").Value = xlOn Then
If InStr(1, Sheets("Grid").Cells(I, L).Value, "ACT") 0 Or _
InStr(1, Sheets("Grid").Cells(I, L).Value, "DEACT") 0 Then
'interior color yellow For Alarms: WARN and ALT
Sheets("Grid").Cells(I, L).Interior.ColorIndex = 6
Sheets("Grid").Cells(I, L + 1).Interior.ColorIndex = 6
Sheets("Grid").Cells(I + 1, L).Interior.ColorIndex = 6
Sheets("Grid").Cells(I + 1, L + 1).Interior.ColorIndex = 6

But what I need is paint on yellow if he find a word "(CC)" in the third
cell

Well my question is . can I have a search or find instead of Value,
"ACT" ?


--

Dave Peterson
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
instr() ? mark kubicki Excel Programming 3 November 16th 06 05:07 PM
Can I save to hard drive AND my flash drive at the same time? Gizelle Excel Discussion (Misc queries) 3 July 24th 06 08:27 PM
InStr Harley Excel Programming 3 August 9th 05 08:55 PM
InStr FGM Excel Programming 3 July 14th 05 08:47 PM
Having a hard time with listbox Thurman Excel Programming 3 September 7th 03 11:22 PM


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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"