Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
.find not finding value
I have the following code to find and replace a values within a range that
works fine most of the time but under some situtations which I have not determined it only seems to look at the current cell. If I select the range first it does work. I have set the breakpoint prior to this code being called and done a find through the interface with out selecting a range. It doesn't the find the value as it only seems to be searching the current cell. In order to get find in the interface working to search the sheet again again I have to select a range first. Do I need to set some other parameter or clear something to make sure it is using my range not the current cell or is my only option to include selection of the range first in the code? Public Function replaceStringInRange(r As range, findstring As String, replacewith As String) As Integer ' finds cells within range replaces string Dim firstaddress As String Dim c As Range Dim count As Integer count = 0 With r Set c = .Find(findstring, LookIn:=xlValues, LookAt:=xlWhole) If Not c Is Nothing Then firstaddress = c.Address Do c.Value = replacewith count = count + 1 Set c = .FindNext(c) If c Is Nothing Then Exit Do End If If c.Address = firstaddress Then Exit Do End If Loop End If End With replaceStringInRange = count End Function |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Find not finding programatically | Excel Programming | |||
.find not finding corect value | Excel Programming | |||
Finding row number with .find() | Excel Programming | |||
Find/Replace not Finding | Excel Discussion (Misc queries) | |||
How do I get the Excel Find function to keep finding what I want? | Excel Discussion (Misc queries) |