This code used to function correctly, however, it has stopped working and I cannot determine why. The computer that runs this file is now using Excel 2007 (it had been Excel 2003). However, this file is now no longer working in 2003 or 2007 and I am stumped.
column "b" data is a hyper link "\\server\share\americolddatafiles\receivedfiles\UnProcessed\testfiledonotuse.txt"
column "c" is either blank or "p"
The idea is for it to find the rows in column "c" that have a "p" in it and move the file referenced in column b to a "processed" folder. Thanks for any assistance.
Code:
Sub filemove()
'
' Created by Brian Birdsong 1/5/11
Dim i As String
Dim fso As Scripting.FileSystemObject
Dim fname As String
'i = "P"
Set fso = New Scripting.FileSystemObject
On Error GoTo Last
For Each n In Range("C1:C100")
Range("B1", ActiveCell.SpecialCells(xlLastCell)).Select
'Selection.Find(What:=i, After:=ActiveCell, LookIn:=xlFormulas, LookAt _
' :=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
' False, SearchFormat:=False).Activate
Selection.Find(What:="P", After:=ActiveCell, LookIn:=xlValues, LookAt:= _
xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False _
, SearchFormat:=False).Activate
'Selects the column "b" cell for file to move
Range(ActiveCell, ActiveCell).Offset(0, -1).Select
'Moves file to processed folder
fname = fso.getfilename(ActiveCell.Offset(0, 1))
fso.MoveFile "O:\AmericoldDataFiles\receivedFiles\Unprocessed\" & fname, "O:\AmericoldDataFiles\receivedfiles\Processed\"
'Selects the B* and C* cells and delets them
Range(ActiveCell, ActiveCell.Offset(0, 2)).Select
Selection.ClearContents
'End If
Next n
Last:
End Sub
column "b" data is a hyper link "\\server\share\americolddatafiles\receivedfiles\UnProcessed\testfiledonotuse.txt"
column "c" is either blank or "p"
The idea is for it to find the rows in column "c" that have a "p" in it and move the file referenced in column b to a "processed" folder. Thanks for any assistance.