PC Review


Reply
Thread Tools Rate Thread

Differences using worksheet functions in worksheet and via VBA

 
 
dbGeezer
Guest
Posts: n/a
 
      22nd Feb 2008
When I use this function in a worksheet (referencing a cell that contains no
spaces), it returns "Is Error" as it should

=IF(ISERROR(LEFT(TRIM(A3),FIND(" ",TRIM(A3)-1))),"Is Error","Is Not Error")

However when I use the VBA version, it throws an Error 1004, "Unable to get
the Find property of the WorksheetFunction class".

If Not IsError(Application.WorksheetFunction.Find(" ",
Trim(ActiveCell.Offset(0, -1)))) Then

I'm trying to parse a very irregular text file into columns.
 
Reply With Quote
 
 
 
 
JMB
Guest
Posts: n/a
 
      22nd Feb 2008
try:
If Not IsError(Application.Find(" ", Trim(ActiveCell.Offset(0, -1)))) Then

or check vba help for the Instr function and use that

or try
On Error Resume Next
x=IsError(Application.WorksheetFunction.Find(" ", Trim(ActiveCell.Offset(0,
-1))))
If Err.Number <> 0 Then
Err.Clear
'There is an error, do Something
Else
'No Error
End If
On Error Goto 0

"dbGeezer" wrote:

> When I use this function in a worksheet (referencing a cell that contains no
> spaces), it returns "Is Error" as it should
>
> =IF(ISERROR(LEFT(TRIM(A3),FIND(" ",TRIM(A3)-1))),"Is Error","Is Not Error")
>
> However when I use the VBA version, it throws an Error 1004, "Unable to get
> the Find property of the WorksheetFunction class".
>
> If Not IsError(Application.WorksheetFunction.Find(" ",
> Trim(ActiveCell.Offset(0, -1)))) Then
>
> I'm trying to parse a very irregular text file into columns.

 
Reply With Quote
 
dbGeezer
Guest
Posts: n/a
 
      22nd Feb 2008
Thanks JMB. The first one worked. I guess that the worksheetfunction class
operates slightly differently than expected.

"JMB" wrote:

> try:
> If Not IsError(Application.Find(" ", Trim(ActiveCell.Offset(0, -1)))) Then
>
> or check vba help for the Instr function and use that
>
> or try
> On Error Resume Next
> x=IsError(Application.WorksheetFunction.Find(" ", Trim(ActiveCell.Offset(0,
> -1))))
> If Err.Number <> 0 Then
> Err.Clear
> 'There is an error, do Something
> Else
> 'No Error
> End If
> On Error Goto 0
>
> "dbGeezer" wrote:
>
> > When I use this function in a worksheet (referencing a cell that contains no
> > spaces), it returns "Is Error" as it should
> >
> > =IF(ISERROR(LEFT(TRIM(A3),FIND(" ",TRIM(A3)-1))),"Is Error","Is Not Error")
> >
> > However when I use the VBA version, it throws an Error 1004, "Unable to get
> > the Find property of the WorksheetFunction class".
> >
> > If Not IsError(Application.WorksheetFunction.Find(" ",
> > Trim(ActiveCell.Offset(0, -1)))) Then
> >
> > I'm trying to parse a very irregular text file into columns.

 
Reply With Quote
 
JMB
Guest
Posts: n/a
 
      22nd Feb 2008
it also does that w/vlookup, hlookup, probably match, and (from a post by
Alan Beban), it appears to mess up Index(SomeRange, ,2 ) where the second
parameter is missing (but s/b assumed to be 0)

"dbGeezer" wrote:

> Thanks JMB. The first one worked. I guess that the worksheetfunction class
> operates slightly differently than expected.
>
> "JMB" wrote:
>
> > try:
> > If Not IsError(Application.Find(" ", Trim(ActiveCell.Offset(0, -1)))) Then
> >
> > or check vba help for the Instr function and use that
> >
> > or try
> > On Error Resume Next
> > x=IsError(Application.WorksheetFunction.Find(" ", Trim(ActiveCell.Offset(0,
> > -1))))
> > If Err.Number <> 0 Then
> > Err.Clear
> > 'There is an error, do Something
> > Else
> > 'No Error
> > End If
> > On Error Goto 0
> >
> > "dbGeezer" wrote:
> >
> > > When I use this function in a worksheet (referencing a cell that contains no
> > > spaces), it returns "Is Error" as it should
> > >
> > > =IF(ISERROR(LEFT(TRIM(A3),FIND(" ",TRIM(A3)-1))),"Is Error","Is Not Error")
> > >
> > > However when I use the VBA version, it throws an Error 1004, "Unable to get
> > > the Find property of the WorksheetFunction class".
> > >
> > > If Not IsError(Application.WorksheetFunction.Find(" ",
> > > Trim(ActiveCell.Offset(0, -1)))) Then
> > >
> > > I'm trying to parse a very irregular text file into columns.

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Compare and highlight differences in 2 worksheets in same workbookand list differences in 3rd worksheet Joshua Houck Microsoft Excel Programming 21 19th Aug 2011 12:21 PM
Optional Variables in Functions (REPLACE and other 'Worksheet' functions) Evi Microsoft Access Queries 2 6th May 2008 09:59 PM
UDF x worksheet functions =?Utf-8?B?Um9nZXJpbyBUYWtlamFtZQ==?= Microsoft Excel Worksheet Functions 3 9th Mar 2006 08:11 PM
Public Functions As Worksheet Available Functions =?Utf-8?B?U3RldmUgS2luZw==?= Microsoft Excel Programming 3 12th Feb 2005 07:55 PM
worksheet functions Random NumNuts Microsoft Excel Discussion 2 9th Jun 2004 02:04 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:00 PM.