• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 521
  • Last Modified:

Delete entire column using named range

I'm missing a basic concept here on assigning ranges. What I am trying to do is delete a column that I have pre-defined as a named range.
I have attached a code snippet.
I am getting an error on line:

The range "rptColSubBatch" is a valid range.
I originally defined the range as comprising the entire column E (i.e. "$E:$E")
The error generated was: Runtime Error '13'  Type Mismatch
I changed the range to comprise only the first cell in the column (i.e. $E$1)
The error generated for that range was: Runtime Error '1004'  Application-defined or Object-defined  error

Because I am working with numerous columns that may change, I need to stick with named ranges.

What am I doing wrong?


Public Sub DeleteColumns()
   Dim strRange As String
   Dim rng As Range
   strRange = "rptColSubBatch"
   Set rng = Range(strRange)
End Sub

Open in new window

1 Solution
shambaladAuthor Commented:
Figured it out.
Public Sub DeleteColumns()
   Dim strRange As String
   strRange = "rptColSubBatch"
end Sub

Open in new window

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Easily Design & Build Your Next Website

Squarespace’s all-in-one platform gives you everything you need to express yourself creatively online, whether it is with a domain, website, or online store. Get started with your free trial today, and when ready, take 10% off your first purchase with offer code 'EXPERTS'.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now