Cells.Replace need to keep track of result
Hello all,
Quick question. I need to keep track of whether or not the Cells.Replace is successful in finding and replacing. I've created a Boolean variable (isfound) and set it to the Cells.Replace and an integer (found_count) for the counter but it (isfound) keeps returning 'True' even though the 'What:=lookup_val' I know didn't find anything. Secondly I need to take the found_count and display this value using a dialogue box. Is this possible if so can anyone provide an example. code snip (xl2k): Dim found_count As Integer Dim isfound As Boolean isfound = repl_wks.Cells.Replace(What:=lookup_val, Replacement:=repl_val, LookAt:=xlPart, SearchOrder _ :=xlByRows, MatchCase:=False) If isfound = True Then found_count = found_count + 1 End If Thanks, Sriram |
Cells.Replace need to keep track of result
Well just figured out that Cells.Replace always returns TRUE. So, is there
a way to track the number of times a 'find & replace' is successfull (ie. number of replacements made)? Thanks, Sriram "Sriram" wrote in message ... Hello all, Quick question. I need to keep track of whether or not the Cells.Replace is successful in finding and replacing. I've created a Boolean variable (isfound) and set it to the Cells.Replace and an integer (found_count) for the counter but it (isfound) keeps returning 'True' even though the 'What:=lookup_val' I know didn't find anything. Secondly I need to take the found_count and display this value using a dialogue box. Is this possible if so can anyone provide an example. code snip (xl2k): Dim found_count As Integer Dim isfound As Boolean isfound = repl_wks.Cells.Replace(What:=lookup_val, Replacement:=repl_val, LookAt:=xlPart, SearchOrder _ :=xlByRows, MatchCase:=False) If isfound = True Then found_count = found_count + 1 End If Thanks, Sriram |
Cells.Replace need to keep track of result
Hello all,
Solved my problem. I used .Find for the counter. Thanks, Sriram "Sriram" wrote in message ... Well just figured out that Cells.Replace always returns TRUE. So, is there a way to track the number of times a 'find & replace' is successfull (ie. number of replacements made)? Thanks, Sriram "Sriram" wrote in message ... Hello all, Quick question. I need to keep track of whether or not the Cells.Replace is successful in finding and replacing. I've created a Boolean variable (isfound) and set it to the Cells.Replace and an integer (found_count) for the counter but it (isfound) keeps returning 'True' even though the 'What:=lookup_val' I know didn't find anything. Secondly I need to take the found_count and display this value using a dialogue box. Is this possible if so can anyone provide an example. code snip (xl2k): Dim found_count As Integer Dim isfound As Boolean isfound = repl_wks.Cells.Replace(What:=lookup_val, Replacement:=repl_val, LookAt:=xlPart, SearchOrder _ :=xlByRows, MatchCase:=False) If isfound = True Then found_count = found_count + 1 End If Thanks, Sriram |
All times are GMT +1. The time now is 01:31 AM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com