Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
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

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
Visual Basic Error Run Time Error, Type Mismatch Meg Partridge Excel Discussion (Misc queries) 12 September 10th 08 06:10 PM
xpath error? Runtime Error 13 type mismatch Steve M[_2_] Excel Discussion (Misc queries) 0 January 17th 08 01:16 AM
xpath error? Runtime Error 13 type mismatch SteveM Excel Discussion (Misc queries) 1 December 4th 07 09:16 AM
Type Mismatch Error David Excel Discussion (Misc queries) 2 December 11th 05 04:46 PM
Type mismatch error Stuart[_5_] Excel Programming 0 August 16th 03 05:20 PM


All times are GMT +1. The time now is 08:53 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"