Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 4615
  • Last Modified:

Excel range from active sheet

I'm writing an Excel 2007 macro and I want to select a certain range from my active worksheet.

I tried using this:
    currRange = ActiveSheet.Range("List1")

But I get the error number 1004 on this line.
I just can't figure it out...
0
Nickman87
Asked:
Nickman87
  • 3
  • 3
1 Solution
 
Patrick MatthewsCommented:
Set currRange = ActiveSheet.Range("List1")
0
 
Patrick MatthewsCommented:
Nickman87,

With object variables, you must use the Set statement.

Regards,

Patrick
0
 
Nickman87Author Commented:
I tried this now :
    Dim currRange As Object
    Set currRange = ActiveSheet.Range("List1")

Still with no succes. I keep on getting the same error on the same spot.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
Patrick MatthewsCommented:
Nickman87,

1) What is the error message?  I do not have the error numbers memorized.

2) Are you quite sure that the name List1 exists, and that it refers to a range on the current
ActiveSheet when the macro hits that line?

Regards,

Patrick
0
 
Nickman87Author Commented:
The error I get is this (in dutch):
        Door de toepassing of het object gedefinieerde fout
Wich is something like this in English:
        Error defined by the application or the object

So, what this actually means is that the object (I guess) is throwing me an Error (for some reason...)

I am sure the name "List1" exist, but could it be a problem that it is defined in two sheets?

Kind regards,
Nick
0
 
Nickman87Author Commented:
I found the problem...
Apparently the Range was not defined... I just tried on another computer and here the range does not exist...

Thanks for you help!
0

Featured Post

 The Evil-ution of Network Security Threats

What are the hacks that forever changed the security industry? To answer that question, we created an exciting new eBook that takes you on a trip through hacking history. It explores the top hacks from the 80s to 2010s, why they mattered, and how the security industry responded.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now