I have a workbook that is connected through an ODBC to web program. Part of the code is supposed to match an invoice from one worksheet to an invoice on another and then add data to it. It is called by a another set of codes... it does not error out and it actually triggers the clear content section, it does not error out, it appears that it is updating the information but it is not really updated... if I walk through the code by pressing F8, it updates with accurate data. This is the code that I am using, I know the code works from beginning to end as long as I press F8 to get through it.. but there is over 700 rows that I am manually looping through... Can someone look at this code and see if there is something that is obvious to you that I am not seeing. Why would it work manually pressing F8 but not actually update when selecting Run?
Sub Refresh_Launch()
'
' Refresh_Launch Macro
'
ActiveWorkbook.RefreshAll
Call MatchInvNo
End Sub
Sub MatchInvNo()
Dim SrcWS As Worksheet
Dim TgtWS As Worksheet
Dim TgtRng As Range
Dim TgtCel As Range
Dim LR As Long
Dim myInv As Range
Dim lookfor As String
DC = Cells(Columns.Count, 1).End(xlUp).Columns
If DC > 1 Then
Range("V2:V" & DC).SpecialCells(xlCellTypeVisible).Columns.ClearContents
End If
Set SrcWS = Sheets("JOBCOST")
Set TgtWS = Sheets("AGING")
With TgtWS
LR = .Range("E" & .Rows.Count).End(xlUp).Row
Set TgtRng = .Range("E2:E" & LR)
For Each TgtCel In TgtRng
lookfor = "Inv: " & TgtCel.Value
Set myInv = SrcWS.Columns(11).Find(lookfor, , xlValues, xlWhole, xlByRows, xlNext, False)
If Not myInv Is Nothing Then
.Cells(TgtCel.Row, "V").Value = SrcWS.Cells(myInv.Row, "F").Value
End If
Next TgtCel
End With
'Call MakeReport
End Sub
Bookmarks