• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 209
  • Last Modified:

Application Defined or Object defined error

Set BaseWks = ActiveSheet

Sheets("GL Summary").Range("A1:G").CurrentRegion.Name = "Ranges"

Open in new window


Hi,

I am getting the 'Application Defined or Object defined error' on above line.

Using examples in this forum, I tried this

Set BaseWks = ActiveSheet

basewks.Range("A1:G").CurrentRegion.Name = "Ranges"

Open in new window


Then it gave me, 'method range of object worksheet failed' error :o

Any help is much appreicated!
I am trying to assign the region as an array for my dynamic pivot table!

Thanks!


0
Shanan212
Asked:
Shanan212
  • 2
  • 2
1 Solution
 
StephenJRCommented:
Try thus:
basewks.Range("A1").CurrentRegion.Name = "Ranges"

Open in new window

0
 
Shanan212Author Commented:
I tried that originally but that picked up unnessary data outside of column G. I got it to work now using this!

    Dim tblRng As Range
    Set tblRng = BaseWks.Range("A1:G" & BaseWks.Range("A" & BaseWks.Rows.Count).End(xlUp).Row)
    tblRng.Name = "Ranges"

Open in new window

0
 
Shanan212Author Commented:
this works now
0
 
StephenJRCommented:
Perhaps you can get in the habit of testing things before you ask the question.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

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