×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

excel macro

excel macro

excel macro

(OP)
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

RE: excel macro

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









Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources