Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
Joe
 
Posts: n/a
Default "Compile error: sub or function not defined"

Hi,

I defined five variables a, b, c. d and argmin (all variant), and then
when I try to use

argmin = min(a,b,c,d),

the compiler says:

"compile error: sub or function not defined"

Do I have to do any special declarations to use the min function?

Please help.

Thanks a lot,

Joe.

  #2   Report Post  
Posted to microsoft.public.excel.misc
Norman Jones
 
Posts: n/a
Default "Compile error: sub or function not defined"

Hi Joe,

Try:

argmin = Application.Min(a, b, c, d)



---
Regards,
Norman



"Joe" wrote in message
oups.com...
Hi,

I defined five variables a, b, c. d and argmin (all variant), and then
when I try to use

argmin = min(a,b,c,d),

the compiler says:

"compile error: sub or function not defined"

Do I have to do any special declarations to use the min function?

Please help.

Thanks a lot,

Joe.



  #3   Report Post  
Posted to microsoft.public.excel.misc
Joe
 
Posts: n/a
Default "Compile error: sub or function not defined"

To provide more context for the above problem, what I was trying to do
was to look at the first four characters in column entries (starting
from I2) for part numbers. (If all four characters are alphabets, the
part number is not valid and the corresponding row entry has to be
deleted). So I tried to use the following macro (modified from another
macro that runs fine):

Sub trimNonlegit()

Dim R As Range
Dim NonLegit As Range
Dim argmin As Variant
Dim a As Variant
Dim b As Variant
Dim c As Variant
Dim d As Variant

Application.ScreenUpdating = False

Set R = Worksheets("Demand").Range("I2")

Do While Not IsEmpty(R)
a = Asc(Mid(R, 1, 1))
b = Asc(Mid(R, 1, 2))
c = Asc(Mid(R, 1, 3))
d = Asc(Mid(R, 1, 4))
argmin = Min(a, b, c, d)
If argmin 57 Then
If NonLegit Is Nothing Then
Set NonLegit = R
Else
Set NonLegit = Union(R, NonLegit)
End If
End If
Set R = R.Offset(1, 0)
Loop

If NonLegit Is Nothing Then
'do nothing
Else
NonLegit.EntireRow.Delete
End If

End Sub

  #4   Report Post  
Posted to microsoft.public.excel.misc
Leith Ross
 
Posts: n/a
Default "Compile error: sub or function not defined"


Hello Joe,

To use an Excel worksheet function in VBA you have use the following
method...

argmin = Application.WorksheetFunction.Min(a, b, c, d)

Sincerely,
Leith Ross


--
Leith Ross
------------------------------------------------------------------------
Leith Ross's Profile: http://www.excelforum.com/member.php...o&userid=18465
View this thread: http://www.excelforum.com/showthread...hreadid=506499

  #5   Report Post  
Posted to microsoft.public.excel.misc
Joe
 
Posts: n/a
Default "Compile error: sub or function not defined"

OOPS! I cant believe I was so stupid! LOL

.... my logic was completely wrong!

Joe.

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
Date & Time mully New Users to Excel 4 May 23rd 05 11:56 AM
Conversion SVC Excel Worksheet Functions 9 February 28th 05 02:29 PM
I cant use englisch function names in a swedich version of excel PE Excel Discussion (Misc queries) 2 December 7th 04 01:00 AM
HOW CAN I GET OFFICE 2003 EXCEL BASIC TO NEST FUNCTIONS LIKE EXCE. Robert AS Excel Worksheet Functions 4 December 2nd 04 10:49 AM
Find a Function to use accross different worksheets R. Hale Excel Worksheet Functions 3 November 25th 04 07:07 AM


All times are GMT +1. The time now is 12:28 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"