IndexOf gives "Invalid qualifier"

rcook
04-22-2008, 03:25 PM
I'm in an Excel VB Macro, attempting to go through my cells with the following:

With ActiveSheet
For currentRow = 1 To .UsedRange.Rows.Count
For currentColumn = 1 To .UsedRange.Columns.Count
Dim currentCell As String
currentCell = RTrim$(.Cells(currentRow, currentColumn).Value)
If Len(currentCell) > 0 Then
If (currentCell.IndexOf(",") > -1) Then specialChars = True
If (currentCell.IndexOf("'") > -1) Then specialChars = True
End If
Next currentColumn
Next currentRow
End With


I am trying to find out if any cell in that range has either a quote or a comma. The program stops on "If (currentCell.IndexOf(",") ...)", saying "Compile error: Invalid qualifier".

I can't figure out what it means. current Cell is declared as a String, IndexOf is a String function, isn't it? Does it matter what's returned from RTrim$()?




Please post Excel questions, in the Excel forum.

Please use the .. tags when you post your code. Edit or reply to this post to see how.

Thank you.

Timbo
04-23-2008, 02:32 AM
If intellisense doesn't show the method you're after, then chances are it's not there ;)

Look up the 'WorksheetFunction' property in your Excel VB help.

But there is a better way to do what you're after; look up the 'Find' method in your Excel VB help. There are also some examples given in the "Excel FAQ 101" thread at the top of this forum.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum