View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson[_3_] Dave Peterson[_3_] is offline
external usenet poster
 
Posts: 2,824
Default Type Mistmatch Error

Do you have any errors in your data div/0!, #ref!, #n/a's?

Option Explicit
Sub testme00()
Dim columnIndex As Long

For columnIndex = 1 To 255
With ActiveSheet.Cells(1, columnIndex)
If IsError(.Value) Then
'do nothing
ElseIf ((.Value) = "Q") Or ((.Value) = "T") Then
Columns(columnIndex).Interior.ColorIndex = 15
End If
End With
Next columnIndex

End Sub

I changed your loop to 1 to 255.
I changed the .cells(columnindex) to .cells(1,columnindex)



Matt wrote:

I am trying to write a macro that will search the first
row of each column and then change the background color of
the column based on its value. Whenever I run the code, I
get a Type 13 Mismatch Error and I am not sure how to fix
it. Any advice?
Here is the source of the problem:

For ColumnIndex = 1 To 1000
With ActiveSheet.Cells(ColumnIndex)
If ((.Value) = "Q") Or ((.Value) = "T") Then
Columns(ColumnIndex).Interior.ColorIndex = 15

Thanks,
Matt


--

Dave Peterson