![]() |
"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. |
"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. |
"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 |
"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 |
"Compile error: sub or function not defined"
OOPS! I cant believe I was so stupid! LOL
.... my logic was completely wrong! Joe. |
All times are GMT +1. The time now is 02:52 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com