Thread: PDF to Excel
View Single Post
 
Old 01-22-2014, 03:45 AM
macropod's Avatar
macropod macropod is offline Windows 7 32bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Hi Shane,

Perhaps you made an error with the changes to the original code I provided. It should now read:
Code:
Sub UpdatePrices()
Application.ScreenUpdating = False
Dim DataSet As String, StrData As String, StrList As String, StrItem As String
Dim i As Long, j As Long, LRow As Long
StrList = ","
With ThisWorkbook
  DataSet = .Path & "\ProductCatalog.txt"
  If Dir(DataSet) <> "" Then
    With .Sheets("Master")
      LRow = .Range("A" & .Rows.Count).End(xlUp).Row
      With .Range("K6:K" & LRow)
        .ClearContents
        .Font.ColorIndex = xlColorIndexAutomatic
      End With
      For i = 6 To LRow
        If Trim(.Range("C" & i).Value) <> "" Then StrList = StrList & .Range("C" & i).Value & ","
      Next
      i = UBound(Split(StrList, ",")) - 1
      Open DataSet For Input As #1
      On Error Resume Next
      Do Until EOF(1)
        Line Input #1, StrData
        StrItem = Split(StrData, " ")(0)
        If InStr(StrList, "," & StrItem & ",") <> 0 Then
          j = UBound(Split(Split(StrList, StrItem)(0), ",")) + 5
          With .Range("K" & j)
            .Value = Trim(Split(StrData, "$")(1))
            If Trim(Split(StrData, "$")(UBound(Split(StrData, "$")))) <> Trim(Split(StrData, "$")(1)) Then .Font.Color = vbRed
          End With
          i = i - 1
        End If
        If i = 0 Then Exit Do
      Loop
      Close #1
    End With
  End If
End With
If i > 0 Then
  MsgBox "Done. However, " & i & " item(s) could not be matched.", vbExclamation
Else
  MsgBox "Done.", vbInformation
End If
Application.ScreenUpdating = True
End Sub
As for the web-related code, I don't have time to review that ATM; especially given that analysing other peoples' code typically takes rather longer than analysing one's own.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote