ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Change cell color after processes - type mismatch (https://www.excelbanter.com/excel-programming/439173-change-cell-color-after-processes-type-mismatch.html)

bailey

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

[email protected]

Change cell color after processes - type mismatch
 
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

On Feb 3, 7:50*pm, Bailey wrote:
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




All times are GMT +1. The time now is 03:16 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com