1

I am trying to delete Column A,B,D,E,F,W,X,Y,Z,AA,AB of the sheet FeuilleFP21. In order to do this I use as seen here and here:

FeuilleFP21.Range("A:B,D:F,W:AB").Delete

But it gives me the following error :

Execution error '1004': The 'Range' method of the '_Worksheet' object failed.

NOTE : FeuilleFP21 is set like that and in Execution window return the name of the sheet when I use ? ?FeuilleFP21.Name

Set FeuilleFP21 = ClasseurFp21.Worksheets(1)

What am I doing wrong ?

15
  • Try to record a macro, deleteing these columns, see the code and repeat it. Commented Oct 16, 2020 at 8:27
  • @Vityata are the answer with tons of upvote false ? Commented Oct 16, 2020 at 8:28
  • @Vityata When I do it manually it does the same but using .Select .. Range("A:B,D:F,W:AB").Select Selection.Delete Commented Oct 16, 2020 at 8:38
  • 1
    It works for me when I tested. Though if I write the string incorrectly I get the same error (used ; instead of , first since this is the list separator on my system). Note that Delete will completely remove the entire columns while Clear will just delete all content. It may be that something is preventing the columns from being deleted? Commented Oct 16, 2020 at 8:40
  • Now write ?ActiveSheet.CodeName and try with this one instead of FeuilleFP21. Commented Oct 16, 2020 at 8:40

1 Answer 1

2

System settings may cause the error. Try separating the columns with ; or whatevery you may have as a "List separator" on your system.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.