View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
bailey bailey is offline
external usenet poster
 
Posts: 22
Default Change cell color after processes - type mismatch

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


--
___________________
Dedicated to learning from the experts