PDA

View Full Version : Subscript out of range



ram567
08-10-2010, 02:44 PM
Hi!
i have the code below which check sendername in outlook to sendername in excel.
if matches it grabs the informaiton received time into excel
i have error in subscript out of range
" Set c = .Find(olItem.SenderName, LookIn:=xlValues, LookAt:=xlPart _, SearchOrder:=SearchOrder, SearchDirection:=SearchDirection, MatchCase:=False _ , SearchFormat:=False) "
could anybody help me.




Dim lResult As Long, oRg As Range
Dim SearchDirection As XlSearchDirection
j = Sheets("Sheet1").Range("A65536").End(xlUp).Row +1
' j = 6
For Each olItem In Fldr.Items
If olItem.To = "xxx" Or olItem.To = "xxx" Or olItem.To = "xxx" Then
If Mid(olItem.Subject, 5, 8) = "Password " Then


With ActiveSheet.Range("A6:A" & j)
Set c = .Find(olItem.SenderName, LookIn:=xlValues _ , LookAt:=xlPart, SearchOrder:=SearchOrder, SearchDirection:=SearchDirection _, MatchCase:=False, SearchFormat:=False)
If Not c Is Nothing Then
Result = c.Row
' pFindRowPos = lResult
ActiveSheet.Cells(Result, 3).Value = olItem.ReceivedTime

End If

End With

End If
j = j +1
End If

Next olItem

gcomyn
08-17-2010, 01:58 PM
from what I can see, if you took the underscores (_) out of the line, it should work.

the underscore (_) is to tell the compiler that the next line should be concatenated to the current line, and if you put them all on one line, you need to take them out.

GComyn
:sleuth: