![]() |
use vba to find two conditions
Hello - I am new to google groups and coding with VBA. I'm hoping
someone can assist with my problem. I think it is kinda easy, I have a pivot table and within column A there is a entry that contains the word 'total', created by the pivot when creating. What I'm looking to do is hight light this row IF the corisponding cell in column F is a negative number. But if the word TOTAL is found and the number in colmun F is positive then, do nothing. I think this might be done via condional formatting as well but not sure of the syntax. |
use vba to find two conditions
Try:
Sub jeff() For i = 1 To 1000 If InStr(Cells(i, 1).Value, "Total") Then If Cells(i, "F").Value < 0 Then Range(Cells(i, 1), Cells(i, 256)).Interior.ColorIndex = 6 End If End If Next End Sub -- Gary's Student " wrote: Hello - I am new to google groups and coding with VBA. I'm hoping someone can assist with my problem. I think it is kinda easy, I have a pivot table and within column A there is a entry that contains the word 'total', created by the pivot when creating. What I'm looking to do is hight light this row IF the corisponding cell in column F is a negative number. But if the word TOTAL is found and the number in colmun F is positive then, do nothing. I think this might be done via condional formatting as well but not sure of the syntax. |
use vba to find two conditions
Gary....thank you very much. That worked perfectly...well, almost. In
your code you have the cell range to 256. I only needed to go to column G, so with one quicky change from 256 to 7....it worked just fine. Thanks again.... Gary''s Student wrote: Try: Sub jeff() For i = 1 To 1000 If InStr(Cells(i, 1).Value, "Total") Then If Cells(i, "F").Value < 0 Then Range(Cells(i, 1), Cells(i, 256)).Interior.ColorIndex = 6 End If End If Next End Sub -- Gary's Student " wrote: Hello - I am new to google groups and coding with VBA. I'm hoping someone can assist with my problem. I think it is kinda easy, I have a pivot table and within column A there is a entry that contains the word 'total', created by the pivot when creating. What I'm looking to do is hight light this row IF the corisponding cell in column F is a negative number. But if the word TOTAL is found and the number in colmun F is positive then, do nothing. I think this might be done via condional formatting as well but not sure of the syntax. |
All times are GMT +1. The time now is 10:38 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com