Hi paul these is two code u gave to me. I try to combine it but come out with error. Please help to arrange these 2 code
Private Sub CommandButton1_Click() Dim rng As Range For Each rng In Range("AC3:AH30") If (rng.Value = "Failed") Then With rng.Interior .Pattern = xlNone .TintAndShade = 0 .PatternTintAndShade = 0 End With rng.FormulaR1C1 = "Passed" End If Next rng End Sub ------------------------------------------------------------------ If (Rng.Value = "Failed") Then If (Not Rng.EntireRow.Hidden) Then With Rng.Interior .Pattern = xlNone .TintAndShade = 0 .PatternTintAndShade = 0 End With Rng.FormulaR1C1 = "Passed" End If End If On 3 Nov 2016 7:31 p.m., "Paul Schreiner" <schreiner_p...@att.net> wrote: > the loop is checking all cells, regardless of whether they are visible or > not. > So, you need to "test" to see if they are hidden. > > In the loop, add: > If (Not Rng.EntireRow.Hidden) Then > > like: > > If (Rng.Value = "Failed") Then > If (Not Rng.EntireRow.Hidden) Then > With Rng.Interior > .Pattern = xlNone > .TintAndShade = 0 > .PatternTintAndShade = 0 > End With > Rng.FormulaR1C1 = "Passed" > End If > End If > > *Paul* > ----------------------------------------- > > > > > > > > *“Do all the good you can,By all the means you can,In all the ways you > can,In all the places you can,At all the times you can,To all the people > you can,As long as ever you can.” - John Wesley* > ----------------------------------------- > > > On Wednesday, November 2, 2016 9:50 PM, Nadal Mir <nadalmi...@gmail.com> > wrote: > > > Hai paul. Thanks the code is working. But im facing another problem. > > If i filter out some data to exclude from the macro. The macro also turn > the data from failed to passed. > > So my question. How to exclude filtered data from running along with the > macro. > > *when I Filter some "failed" data out from the range, the macro also turn > it to "passed". > > How to exclude that? > > Thanks in advance > > > -- > Are you =EXP(E:RT) or =NOT(EXP(E:RT)) in Excel? And do you wanna be? It’s > =TIME(2,DO:IT,N:OW) ! Join official Facebook page of this forum @ > https://www.facebook.com/discussexcel > > FORUM RULES > > 1) Use concise, accurate thread titles. Poor thread titles, like Please > Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice > will not get quick attention or may not be answered. > 2) Don't post a question in the thread of another member. > 3) Don't post questions regarding breaking or bypassing any security > measure. > 4) Acknowledge the responses you receive, good or bad. > 5) Jobs posting is not allowed. > 6) Sharing copyrighted material and their links is not allowed. > > NOTE : Don't ever post confidential data in a workbook. Forum owners and > members are not responsible for any loss. > --- > You received this message because you are subscribed to the Google Groups > "MS EXCEL AND VBA MACROS" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to excel-macros+unsubscr...@googlegroups.com. > To post to this group, send email to excel-macros@googlegroups.com. > Visit this group at https://groups.google.com/group/excel-macros. > For more options, visit https://groups.google.com/d/optout. > > > -- > Are you =EXP(E:RT) or =NOT(EXP(E:RT)) in Excel? And do you wanna be? It’s > =TIME(2,DO:IT,N:OW) ! Join official Facebook page of this forum @ > https://www.facebook.com/discussexcel > > FORUM RULES > > 1) Use concise, accurate thread titles. Poor thread titles, like Please > Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice > will not get quick attention or may not be answered. > 2) Don't post a question in the thread of another member. > 3) Don't post questions regarding breaking or bypassing any security > measure. > 4) Acknowledge the responses you receive, good or bad. > 5) Jobs posting is not allowed. > 6) Sharing copyrighted material and their links is not allowed. > > NOTE : Don't ever post confidential data in a workbook. Forum owners and > members are not responsible for any loss. > --- > You received this message because you are subscribed to a topic in the > Google Groups "MS EXCEL AND VBA MACROS" group. > To unsubscribe from this topic, visit https://groups.google.com/d/ > topic/excel-macros/85Ww3m1Wd5U/unsubscribe. > To unsubscribe from this group and all its topics, send an email to > excel-macros+unsubscr...@googlegroups.com. > To post to this group, send email to excel-macros@googlegroups.com. > Visit this group at https://groups.google.com/group/excel-macros. > For more options, visit https://groups.google.com/d/optout. > -- Are you =EXP(E:RT) or =NOT(EXP(E:RT)) in Excel? And do you wanna be? It’s =TIME(2,DO:IT,N:OW) ! Join official Facebook page of this forum @ https://www.facebook.com/discussexcel FORUM RULES 1) Use concise, accurate thread titles. Poor thread titles, like Please Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get quick attention or may not be answered. 2) Don't post a question in the thread of another member. 3) Don't post questions regarding breaking or bypassing any security measure. 4) Acknowledge the responses you receive, good or bad. 5) Jobs posting is not allowed. 6) Sharing copyrighted material and their links is not allowed. NOTE : Don't ever post confidential data in a workbook. Forum owners and members are not responsible for any loss. --- You received this message because you are subscribed to the Google Groups "MS EXCEL AND VBA MACROS" group. To unsubscribe from this group and stop receiving emails from it, send an email to excel-macros+unsubscr...@googlegroups.com. To post to this group, send email to excel-macros@googlegroups.com. Visit this group at https://groups.google.com/group/excel-macros. For more options, visit https://groups.google.com/d/optout.