Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 789
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Change the color of a cell when I type a certain word. Rickie Gibson Excel Programming 3 February 21st 08 10:22 PM
Type mismatch when copy empty cell to Access database Angus Excel Programming 1 May 30th 07 05:51 PM
Type Mismatch: array or user defined type expected ExcelMonkey Excel Programming 4 July 6th 06 03:40 PM
Help: Compile error: type mismatch: array or user defined type expected lvcha.gouqizi Excel Programming 1 October 31st 05 08:20 PM
Pivot Tables Formatting interior color &Type Mismatch CraigS Excel Programming 0 January 8th 05 07:45 PM


All times are GMT +1. The time now is 05:07 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"