Hi I'm working on some code in VBA in Excel 2010 and I'm running into a problem with preexisting code in the spreadsheet. My code reads in data from another workbook and posts the value in a certain cell, which works fine. However, there is code that is already there which causes an infinite loop, and I have no idea how to fix it. My code runs fine and whenever I stop the code the value will paste, but otherwise it just gets stuck between these two functions from the preexisting code.
The preexisting code populates the cells and looks like this:
Function WORD(PHRASE, TIME, FOLLOWING)
If FOLLOWING = 0 Then
WORD = 0
ElseIf TIME = FOLLOWING Then
WORD = 0
ElseIf PHRASE Like "5 Min C/O" Then
WORD = 0
ElseIf PHRASE = "10 Min C/O" Then
WORD = 0
ElseIf PHRASE Like "15 Min C/O*" Then
WORD = 0
ElseIf PHRASE Like "20 Min C/O" Then
WORD = 0
ElseIf PHRASE Like "30 Min C/O" Then
WORD = 0
ElseIf PHRASE Like "Continued" Then
WORD = 0
ElseIf PHRASE Like "End" Then
WORD = 0
Else: WORD = TIME
End If
End Function
Function DELETE(PRESENT, PAST)
If PRESENT = PAST Then
DELETE = 0
Else: DELETE = PRESENT
End If
ALSO: Along with this code is this written into the spreadsheet
=IF((ISERROR(VLOOKUP($D6,'\\BBUROCKFSXXPP01\Public\Production\####Orders\[Mixer Exceptions.xlsx]Sheet 1'!$A$4:$S$45,2,TRUE)=TRUE))," ",VLOOKUP($D6,'\\BBUROCKFSXXPP01\Public\Production\####Orders\[Mixer Exceptions.xlsx]Sheet 1'!$A$4:$S$45,2))
The preexisting code populates the cells and looks like this:
Function WORD(PHRASE, TIME, FOLLOWING)
If FOLLOWING = 0 Then
WORD = 0
ElseIf TIME = FOLLOWING Then
WORD = 0
ElseIf PHRASE Like "5 Min C/O" Then
WORD = 0
ElseIf PHRASE = "10 Min C/O" Then
WORD = 0
ElseIf PHRASE Like "15 Min C/O*" Then
WORD = 0
ElseIf PHRASE Like "20 Min C/O" Then
WORD = 0
ElseIf PHRASE Like "30 Min C/O" Then
WORD = 0
ElseIf PHRASE Like "Continued" Then
WORD = 0
ElseIf PHRASE Like "End" Then
WORD = 0
Else: WORD = TIME
End If
End Function
Function DELETE(PRESENT, PAST)
If PRESENT = PAST Then
DELETE = 0
Else: DELETE = PRESENT
End If
ALSO: Along with this code is this written into the spreadsheet
=IF((ISERROR(VLOOKUP($D6,'\\BBUROCKFSXXPP01\Public\Production\####Orders\[Mixer Exceptions.xlsx]Sheet 1'!$A$4:$S$45,2,TRUE)=TRUE))," ",VLOOKUP($D6,'\\BBUROCKFSXXPP01\Public\Production\####Orders\[Mixer Exceptions.xlsx]Sheet 1'!$A$4:$S$45,2))