Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
Yossi
 
Posts: n/a
Default Can't use WorksheetFunction

Hi,
I am trying to use the WorsheeFunction property within a user form, but the
VBA claims it can't get the method I want to use out of the worksheetFunction
class.
Why is that?
  #2   Report Post  
Posted to microsoft.public.excel.misc
Dave Peterson
 
Posts: n/a
Default Can't use WorksheetFunction

What worksheet function?

Some aren't available in VBA. But VBA's help shows which ones are.

Yossi wrote:

Hi,
I am trying to use the WorsheeFunction property within a user form, but the
VBA claims it can't get the method I want to use out of the worksheetFunction
class.
Why is that?


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.misc
Yossi
 
Posts: n/a
Default Can't use WorksheetFunction

for example the MATCH function.
I used it somewhere else (not in a user form) and it works, so I am a bit
puzzled as to why it doesn't work here.

basically I am triggering the function when the user selects something from
the list box I gave him.

"Dave Peterson" wrote:

What worksheet function?

Some aren't available in VBA. But VBA's help shows which ones are.

Yossi wrote:

Hi,
I am trying to use the WorsheeFunction property within a user form, but the
VBA claims it can't get the method I want to use out of the worksheetFunction
class.
Why is that?


--

Dave Peterson

  #4   Report Post  
Posted to microsoft.public.excel.misc
Dave Peterson
 
Posts: n/a
Default Can't use WorksheetFunction

dim res as variant 'in case of an error returned
dim lookupRng as range
dim lookupVal as variant

with worksheets("sheet99")
set lookuprng = .range("a2",.cells(.rows.count,"A").end(xlup))
end with

set lookupval = worksheets("sheet77").range("a99")

res = application.match(lookupval.value,lookuprng,0)

if iserror(res) then
'not found
else
'it was found
end if

There are function (=vlookup() and =match() come to mind) that cause a run time
error if you use:

application.worksheetfunction.match()

But you can code around it (I just find the previous method easier):

dim res as long
'''same as that other stuff

on error resume next
res = application.match(lookupval.value,lookuprng,0)
if err.number < 0 then
'no match
err.clear
else
'it was found
end if
on error goto 0






Yossi wrote:

for example the MATCH function.
I used it somewhere else (not in a user form) and it works, so I am a bit
puzzled as to why it doesn't work here.

basically I am triggering the function when the user selects something from
the list box I gave him.

"Dave Peterson" wrote:

What worksheet function?

Some aren't available in VBA. But VBA's help shows which ones are.

Yossi wrote:

Hi,
I am trying to use the WorsheeFunction property within a user form, but the
VBA claims it can't get the method I want to use out of the worksheetFunction
class.
Why is that?


--

Dave Peterson


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.misc
Yossi
 
Posts: n/a
Default Can't use WorksheetFunction

Thanks a lot, man, for the help :-)

"Dave Peterson" wrote:

dim res as variant 'in case of an error returned
dim lookupRng as range
dim lookupVal as variant

with worksheets("sheet99")
set lookuprng = .range("a2",.cells(.rows.count,"A").end(xlup))
end with

set lookupval = worksheets("sheet77").range("a99")

res = application.match(lookupval.value,lookuprng,0)

if iserror(res) then
'not found
else
'it was found
end if

There are function (=vlookup() and =match() come to mind) that cause a run time
error if you use:

application.worksheetfunction.match()

But you can code around it (I just find the previous method easier):

dim res as long
'''same as that other stuff

on error resume next
res = application.match(lookupval.value,lookuprng,0)
if err.number < 0 then
'no match
err.clear
else
'it was found
end if
on error goto 0






Yossi wrote:

for example the MATCH function.
I used it somewhere else (not in a user form) and it works, so I am a bit
puzzled as to why it doesn't work here.

basically I am triggering the function when the user selects something from
the list box I gave him.

"Dave Peterson" wrote:

What worksheet function?

Some aren't available in VBA. But VBA's help shows which ones are.

Yossi wrote:

Hi,
I am trying to use the WorsheeFunction property within a user form, but the
VBA claims it can't get the method I want to use out of the worksheetFunction
class.
Why is that?

--

Dave Peterson


--

Dave Peterson



  #6   Report Post  
Posted to microsoft.public.excel.misc
Dave Peterson
 
Posts: n/a
Default Can't use WorksheetFunction

You're welcome.

Yossi wrote:

Thanks a lot, man, for the help :-)

"Dave Peterson" wrote:

dim res as variant 'in case of an error returned
dim lookupRng as range
dim lookupVal as variant

with worksheets("sheet99")
set lookuprng = .range("a2",.cells(.rows.count,"A").end(xlup))
end with

set lookupval = worksheets("sheet77").range("a99")

res = application.match(lookupval.value,lookuprng,0)

if iserror(res) then
'not found
else
'it was found
end if

There are function (=vlookup() and =match() come to mind) that cause a run time
error if you use:

application.worksheetfunction.match()

But you can code around it (I just find the previous method easier):

dim res as long
'''same as that other stuff

on error resume next
res = application.match(lookupval.value,lookuprng,0)
if err.number < 0 then
'no match
err.clear
else
'it was found
end if
on error goto 0






Yossi wrote:

for example the MATCH function.
I used it somewhere else (not in a user form) and it works, so I am a bit
puzzled as to why it doesn't work here.

basically I am triggering the function when the user selects something from
the list box I gave him.

"Dave Peterson" wrote:

What worksheet function?

Some aren't available in VBA. But VBA's help shows which ones are.

Yossi wrote:

Hi,
I am trying to use the WorsheeFunction property within a user form, but the
VBA claims it can't get the method I want to use out of the worksheetFunction
class.
Why is that?

--

Dave Peterson


--

Dave Peterson


--

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
WorksheetFunction Documentation P-A Caron Excel Worksheet Functions 1 April 12th 05 03:12 PM
WorksheetFunction with VBA Ghislain Marcotte Excel Discussion (Misc queries) 2 February 13th 05 07:08 AM
"Unable to get the NormSInv property of the WorksheetFunction clas David Roodman Excel Worksheet Functions 1 December 15th 04 12:15 PM


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