Rabu, 19 September 2012

Re: [ExcelVBA] help with "If IsError .. "

 

It looks like your code is designed to search the column headings in row 1
to find a cell that has the word "multiple" in it.

There seems to be multiple problems.
#1) While colF < 1
I'm assuming you have set colF to a value prior to this section of code.
In order for this to evaluate to TRUE, the column you're testing would have to
be column number 0 or a negative.
Which will never happen.

#2) Since colF MUST be greater than 0, then your macro should've never even
REACHED your search line.
So, I must assume that you mis-keyed it when you posted it, and you actually
are using While colF > 1
But then, since you're increasing the column numbers (colF = colF + 1) then the
macro will continue to run
until you reach the maximum column (16384) then error out.
unless you put in a exitloop when the string is found.

#3) When the search doesn't find anything, the Worksheetfunction retruns a VBA
Error/run time error.
the ISerror function expects the value to be a numeric value that REPRESENTS
an error.

What I would do is use use VBA Error handler:
--------------------------------------------------------
On Error Resume Next
For ColF = 1 to ActiveCell.SpecialCells(xlLastCell).Column
    Err.Clear
    Multiple = Application.WorksheetFunction.Search("Multiple", WkShtf.Cells(1,
ColF).Value, 1)
    If (Err.Number = 0) Then
        Cells(ColF, 2).Select
        Exit For
    End If
Next ColF
-------------------------------------------------------
Paul
-----------------------------------------
"Do all the good you can,
By all the means you can,
In all the ways you can,
In all the places you can,
At all the times you can,
To all the people you can,
As long as ever you can." - John Wesley
-----------------------------------------

________________________________
From: HawtSweetie240 <tapmba@yahoo.com>
To: ExcelVBA@yahoogroups.com
Sent: Tue, September 18, 2012 7:17:00 PM
Subject: [ExcelVBA] help with "If IsError .. "

 
Could some one please help me find the issue that is causing error in the part
of the code below? I am basically getting error is the If IsError part of the
code

Do While colF < 1
If IsError(WorksheetFunction.Search("Multiple", wkShtF.Cells(1, colF), 1)) Then
0
colF = colF + 1
Else
multiple = WorksheetFunction.Search("Multiple", wkShtF.Cells(1, colF), 1)
colF = colF + 1
End If
Loop

Thank you in advance

[Non-text portions of this message have been removed]

__._,_.___
Recent Activity:
----------------------------------
Be sure to check out TechTrax Ezine for many, free Excel VBA articles! Go here: http://www.mousetrax.com/techtrax to enter the ezine, then search the ARCHIVES for EXCEL VBA.

----------------------------------
Visit our ExcelVBA group home page for more info and support files:
http://groups.yahoo.com/group/ExcelVBA

----------------------------------
More free tutorials and resources available at:
http://www.mousetrax.com

----------------------------------
.

__,_._,___

Tidak ada komentar:

Posting Komentar