Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Change the color of a cell when I type a certain word. | Excel Programming | |||
Type mismatch when copy empty cell to Access database | Excel Programming | |||
Type Mismatch: array or user defined type expected | Excel Programming | |||
Help: Compile error: type mismatch: array or user defined type expected | Excel Programming | |||
Pivot Tables Formatting interior color &Type Mismatch | Excel Programming |