1004: Activate method of Range class failed

A

Alan

I get an error when the code below is executed.

With ThisWorkbook.Sheets("table").Cells(27 + n - 1, 2)
.Activate
End With

The first line evaluates to:

ThisWorkbook.Sheets("table").Cells(27,2)

--- Cell B27, which is a merger of Cells B27:M27 --- in this case.

I get the following error: 1004: Activate method of Range class
failed.

Any idea why I am getting this error? Thanks, Alan
 
D

Dave Peterson

You can only activate or select a range on the activesheet.

So I'm guessing that table isn't the activesheet in ThisWorkbook--or
thisworkbook isn't the activeworkbook.

I'd use:

with thisworkbook
.activate
with .sheets("table")
.select 'activate???
with .cells(27 + n - 1, 2)
.activate
end with
end with
end with

But there aren't many things in excel/VBA that require you to select or activate
a range/worksheet/workbook/object...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top