Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old January 18th, 2011, 08:43 AM
Authorized User
Join Date: Apr 2009
Posts: 23
Thanks: 1
Thanked 0 Times in 0 Posts
Default What is wrong with this range syntax

Hi friends

A very basic problem I am confronted with toady:

Dim myRange As Range
Set myRange = Range("a:a, d:d, e:e")

Actual report has far more columns to delete, so a marco like this would really help a lot.

Old January 18th, 2011, 10:50 AM
JP JP is offline
Authorized User
Join Date: Apr 2008
Posts: 57
Thanks: 1
Thanked 3 Times in 3 Posts

In general, you don't need to select an object before manipulating it. Try this:

Dim myRange As Range
Set myRange = Range("a:a, d:d, e:e")
Since "EntireColumn" is a child object of the Range object, and you set a reference to a Range, object, you can use it directly without having to first select the range. Also, since the Range object itself refers to entire columns, you can also call the Delete method directly. This would also work:

Dim myRange As Range
Set myRange = Range("a:a, d:d, e:e")
JP SoftTech
The Following User Says Thank You to JP For This Useful Post:
SMI// (January 5th, 2016)

Similar Threads
Thread Thread Starter Forum Replies Last Post
Is this worded wrong or am I reading wrong? notig BOOK: Beginning Visual C# 2010 1 September 25th, 2010 01:51 PM
Syntax Error on Date Range skwilliams Classic ASP Databases 4 February 13th, 2006 01:11 PM
what is wrong with this syntax crmpicco Classic ASP Databases 2 February 23rd, 2005 11:59 PM
Date Range mrideout BOOK: Beginning ASP.NET 1.0 0 January 2nd, 2005 07:18 PM
Anyone knows what is wrong with this syntax? kasie MySQL 1 June 11th, 2004 09:41 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.