0

I was supposed to clear contents in a cell, but an error-message appeared. And I no longer can activate or do anything in the sheet...

I have tried thing like:

ThisWorkbook.ActiveSheet.Range("A1").Select". This do not work.

If I try to select the worksheet, run-time error 1004 appear again with the new text Method 'Select' of Object '_Worksheet' failed

If I try to activate the workbook, even then I get the problem: Method 'Activate' of object '_Workbook' failed.

I saw these were the solution in this forum, however these did not work for me unfortunately: Run Time Error '1004': Select method of Range Class failed using ThisWorkbook

I am thankfull for any help I can get. Will look at it tomorrow. Regards Hallvard

enter image description here

enter image description here

enter image description here

  • 2
    No need to select first. `ws2.Range("U6").ClearContents` should work without select first. – CDP1802 Jun 22 '23 at 15:02
  • 2
    You will get better quality answers if you paste the code. Watch: [Excel VBA Introduction Part 5 - Selecting Cells (Range, Cells, Activecell, End, Offset)](https://www.youtube.com/watch?v=c8reU-H1PKQ&t=76s) – TinMan Jun 22 '23 at 15:04
  • Can you show us your declaration of your workbook/worksheet and how you set them? That you can't even activate your workbook seems odd to say the least. – Notus_Panda Jun 22 '23 at 15:29
  • You might benefit from reading [How to avoid using Select in Excel VBA](https://stackoverflow.com/q/10714251/4996248). The best way to debug `Select` based code is often to rewrite the code to avoid it entirely. – John Coleman Jun 22 '23 at 15:32
  • I am sorry guys, but I am not able to reproduce the error and hence go further on this one. The code is now suddenly working. And CDP1802, that was my original code (no selection). But since the error first appeared, I tried all kinds of "easy tasks" just to see what works and not. Getting the name of the workbook, the sheet etc. worked, but not interaction with the range within the sheets... The code(s) are massive, so it would probably not be the best to give away such a huge task to any one to inspect it. – Hallvard Skrede Jun 23 '23 at 08:57
  • And thanks to all of you, for the tips, will have a look on these, if it occurs again. :) (I will check out the pages you recommended anyways) – Hallvard Skrede Jun 23 '23 at 09:02

0 Answers0