Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Differences using worksheet functions in worksheet and via VBA

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.
  #2   Report Post  
Posted to microsoft.public.excel.programming
JMB JMB is offline
external usenet poster
 
Posts: 2,062
Default Differences using worksheet functions in worksheet and via VBA

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.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Differences using worksheet functions in worksheet and via VBA

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.

  #4   Report Post  
Posted to microsoft.public.excel.programming
JMB JMB is offline
external usenet poster
 
Posts: 2,062
Default Differences using worksheet functions in worksheet and via VBA

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
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
Worksheet functions in VBA Builder[_2_] Excel Programming 2 April 19th 07 02:08 AM
UDF x worksheet functions Rogerio Takejame Excel Worksheet Functions 3 March 9th 06 08:11 PM
Worksheet functions Joe D. Excel Worksheet Functions 0 March 8th 06 02:24 PM
Public Functions As Worksheet Available Functions Steve King Excel Programming 3 February 12th 05 07:55 PM
worksheet functions Gmet[_2_] Excel Programming 1 September 3rd 04 04:07 PM


All times are GMT +1. The time now is 06:09 AM.

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"