Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations cowski on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

excel macro

Status
Not open for further replies.

bigb

Mechanical
Sep 17, 2002
12
Hi

when I run my macro for excel in Visual basic I find this error:

Runtime error 1004

Method 'Range' of object' - Global' failed

I think the error is in this statement:

y = funct("abc", Range("abc"), 1)

--------------
The function has been defined as follows:

Declare Function funct Lib "hello.XLL" (ByVal sheetName As Variant, ByVal Range As Variant, ByVal lockFlag As Variant) As Long



I tried y = funct("abc", "Range(abc)", 1)
but then the program is working and result is wrong

Could you help me fix this problem.
Thanks
bigb
 
Replies continue below

Recommended for you

Firstly, 'Range' us a reserved word and you should not use it as an argument name in the Function declaration. Try using 'Rng' instead.

Function funct(ByVal sheetName As Variant, ByVal Range As Variant, ByVal lockFlag As Variant) As Long

Secondly for the function call:

y = funct("abc", Range("abc"), 1)

to work, "abc" must be a named range in the workbook - and from the look of your function, should most likely contain a string...

Good luck









 
Status
Not open for further replies.

Part and Inventory Search

Sponsor