Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
replace a negative result with a zero? | Excel Discussion (Misc queries) | |||
How to replace formula with its result | Excel Worksheet Functions | |||
Replace a vlookup #N/A result with a value | Excel Worksheet Functions | |||
Replace ^ in web query result | Excel Worksheet Functions | |||
Replace data with the result of a formula | Excel Discussion (Misc queries) |