Prev: How to use Excel to determine cutting and reusing stock to fill or
Next: Content Size for WebBrowser ActiveX Control
From: Alan on 8 Sep 2009 19:16 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
From: Dave Peterson on 8 Sep 2009 19:24
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... Alan wrote: > > 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 -- Dave Peterson |