J
Jim Thomlinson
In short my question is this... Is there some kind of issue using FindNext in
the Before_Save Event?
Here is what I am up to. I have a spreadsheet being used remotely by a bunch
of end users. It updates a DB2 database here at head office via ADODB
recordsets. The trigger that I am using to send the data is that the data is
sent any time the user saves their spreadsheet. The spreadsheet determines
what data needs to be appended or updated in the database using some formulas
which flag the items with the word Update or Append. That is pretty straight
forward stuff. Here is what is happening that is causing me some concern
though. If I call the write procedure from the Before_Save Event in
ThisWorkbook it has a problem with this code...
Private Function FoundRange(ByVal strInput As String, ByVal rngToSearch As
Range) As Range
Dim rngFound As Range
Dim strFirstAddress As String
Set rngFound = rngToSearch.Find(What:=strInput, _
LookAt:=xlWhole, _
LookIn:=xlValues, _
MatchCase:=False)
If rngFound Is Nothing Then
Set FoundRange = Nothing
Else
Set FoundRange = rngFound
strFirstAddress = rngFound.Address
Do
Set FoundRange = Union(FoundRange, rngFound)
Set rngFound = rngToSearch.FindNext(rngFound)
Loop Until rngFound.Address = strFirstAddress
End If
End Function
It finds the first item and sets rngFound correctly, but when it proceeds to
the FindNext, rngFound is set to nothing (What the Heck!). If I call the
write procedure not from the before save event it works great. Is there some
kind of issue using FindNext in the Before_Save Event?
the Before_Save Event?
Here is what I am up to. I have a spreadsheet being used remotely by a bunch
of end users. It updates a DB2 database here at head office via ADODB
recordsets. The trigger that I am using to send the data is that the data is
sent any time the user saves their spreadsheet. The spreadsheet determines
what data needs to be appended or updated in the database using some formulas
which flag the items with the word Update or Append. That is pretty straight
forward stuff. Here is what is happening that is causing me some concern
though. If I call the write procedure from the Before_Save Event in
ThisWorkbook it has a problem with this code...
Private Function FoundRange(ByVal strInput As String, ByVal rngToSearch As
Range) As Range
Dim rngFound As Range
Dim strFirstAddress As String
Set rngFound = rngToSearch.Find(What:=strInput, _
LookAt:=xlWhole, _
LookIn:=xlValues, _
MatchCase:=False)
If rngFound Is Nothing Then
Set FoundRange = Nothing
Else
Set FoundRange = rngFound
strFirstAddress = rngFound.Address
Do
Set FoundRange = Union(FoundRange, rngFound)
Set rngFound = rngToSearch.FindNext(rngFound)
Loop Until rngFound.Address = strFirstAddress
End If
End Function
It finds the first item and sets rngFound correctly, but when it proceeds to
the FindNext, rngFound is set to nothing (What the Heck!). If I call the
write procedure not from the before save event it works great. Is there some
kind of issue using FindNext in the Before_Save Event?