Getting the runtime error 1004 when running the following macro that has columns ranging from A to BJ.

Sub sbVBS_To_Delete_Specific_Multiple_Columns()
Sheets("GRT Flight Data Log_raw").Range("A:B,H:I,K:L,P,AB:AH,AK:AN,AQ,AT,AZ:BJ").EntireColumn.Delete
End Sub

I have used this code on the same data log deleting different columns for a different application and it works just fine. This is the code that works:

Sub sbVBS_To_Delete_Specific_Multiple_Columns()

Sheets("GRT Flight Data Log").Range("A:B,H:L,P:Q,S:BJ").EntireColumn.Delete
End Sub

I have exhausted every possibility I have found, please help.

  • Not sure about your problem. But is "P" a range? Maybe you need to do "P:P" – Yisroel Tech Jan 23 '17 at 17:41
  • You are right my ranges had single column set so I changed all single column values to reflect that i.e. AQ is now AQ:AQ and P is now P:P like you said thanks. – Christopher Rogers Jan 23 '17 at 17:50
  • "runtime error 1004" is all the error says? It should say something more detailed. – Yisroel Tech Jan 23 '17 at 17:54
  • It did say more about ranges but you solved it regardless so thanks. – Christopher Rogers Jan 23 '17 at 21:36
  • Oh, you edited that comment. Thought you weren't helped. I'll write my comment as answer so it can be accepted. – Yisroel Tech Jan 23 '17 at 22:55

I see that in ranges you have P which is not a range but a single letter.

You should change that to something like P:P

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.