1004: Activate method of Range class failed

  • Thread starter Thread starter Alan
  • Start date Start date
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
 
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...
 
Back
Top