Change cell color after processes - type mismatch

B

Bailey

In this program which works until I added the .cells color - basically I
want to color the cell if it existed and was moved or a different color if
the file was not found.

I keep getting a type mismatch. The code is below.

'Primary program
'
Sub RunThroughList()
Dim I As Long
Dim Destination As String
Dim Lastrow As Long

Lastrow = Worksheets(1).Cells(Rows.Count, 1).End(xlUp).Row
For I = 1 To Lastrow
MoveFiles Range("A" & I).Value, "P:\Web_ICC\Archive_Test\", I
Cells("A", I).Interior.ColorIndex = 6
Next
End Sub

'Sub routine
'http://tinyurl.com/y9h5vzx

Public Sub MoveFiles(ByVal Source As String, ByVal Destination As String,
ByVal Counter As Long)
Dim oFSO As Object
Set oFSO = CreateObject("Scripting.FileSystemObject")
With oFSO
If .FileExists(Source) Then
..MoveFile Source, Destination
Else
MsgBox Source & " Doesn't Exist", vbExclamation
Cells("A", I).Interior.ColorIndex = 7
End If
End With
Set oFSO = Nothing
End Sub
 
P

paul.robinson

Hi
Can't see how adding that line would do much. t a pinch, should Source
be a variant or replace with
Cstr(Range("A" & I).Value) to force it to be a string?
regards
Paul
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top