PC Review


Reply
Thread Tools Rate Thread

Deleting column in a worksheet that is not active worksheet

 
 
kansaskannan@gmail.com
Guest
Posts: n/a
 
      4th Oct 2007

Could anyone please tell me

(a) Why the following line of code will work only if "Test" is the
active worksheet.
Sheets("Test").Cells(1, 1).EntireColumn.Delete

(b) How can I delete a column in a particular worksheet without
selecting that worksheet.

Thank you very much.

 
Reply With Quote
 
 
 
 
=?Utf-8?B?SmltIFRob21saW5zb24=?=
Guest
Posts: n/a
 
      4th Oct 2007
That exact code works on my machine to delete column 1. A little shorter
would be

Sheets("Test").Columns(1).Delete

but that is just a matter of preference...
--
HTH...

Jim Thomlinson


"(E-Mail Removed)" wrote:

>
> Could anyone please tell me
>
> (a) Why the following line of code will work only if "Test" is the
> active worksheet.
> Sheets("Test").Cells(1, 1).EntireColumn.Delete
>
> (b) How can I delete a column in a particular worksheet without
> selecting that worksheet.
>
> Thank you very much.
>
>

 
Reply With Quote
 
dan dungan
Guest
Posts: n/a
 
      4th Oct 2007
I'm using excel 2000 on xp pro.

I used:

Sub test()
Sheets("Test").Cells(1, 1).EntireColumn.Delete
End Sub

It seemed to work if I put the the sub in the Sheet1 module or in
ThisWorkbook module.

I couldn't get it to fail.

Dan

On Oct 3, 4:58 pm, kansaskan...@gmail.com wrote:
> Could anyone please tell me
>
> (a) Why the following line of code will work only if "Test" is the
> active worksheet.
> Sheets("Test").Cells(1, 1).EntireColumn.Delete
>
> (b) How can I delete a column in a particular worksheet without
> selecting that worksheet.
>
> Thank you very much.



 
Reply With Quote
 
kansaskannan@gmail.com
Guest
Posts: n/a
 
      7th Oct 2007
Jim Thomlinson, Dan Dungan:

Thanks for the courtesy of your response. I have been repeating that
code, and it works, as both of you indicated. Despite several
attempts, I have not been able to reproduce the error from my earlier
workbook that was making me more than a little frustrated. I hope I
did not waste too much of your time. Jim Thomlinson, Thanks for
suggesting the shorter version for deleting columns.


---------------------------------------------------------------------------
That exact code works on my machine to delete column 1. A little
shorter
would be
Sheets("Test").Columns(1).Delete
but that is just a matter of preference...
--
HTH...
Jim Thomlinson
---------------------------------------------------------------------------
I'm using excel 2000 on xp pro

I'm using excel 2000 on xp pro.
I used:
Sub test()
Sheets("Test").Cells(1, 1).EntireColumn.Delete
End Sub
It seemed to work if I put the the sub in the Sheet1 module or in
ThisWorkbook module.
I couldn't get it to fail.
Dan Dungan


On Oct 3, 7:58 pm, kansaskan...@gmail.com wrote:
> Could anyone please tell me
>
> (a) Why the following line of code will work only if "Test" is the
> active worksheet.
> Sheets("Test").Cells(1, 1).EntireColumn.Delete
>
> (b) How can I delete a column in a particular worksheet without
> selecting that worksheet.
>
> Thank you very much.



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Basic Question - How do I return the worksheet number of the active worksheet? Regnab Microsoft Excel Programming 2 17th May 2006 03:02 AM
Active cell, row, column, worksheet, etc =?Utf-8?B?c2lwODMxNg==?= Microsoft Excel Programming 2 6th Jun 2005 02:29 PM
Report All Column Widths In Active Worksheet - Corrected DataFreakFromUtah Microsoft Excel Programming 1 22nd Jul 2004 01:13 PM
Report All Column Widths In Active Worksheet - an example DataFreakFromUtah Microsoft Excel Programming 2 21st Jul 2004 06:09 PM
macro to apply worksheet event to active worksheet Paul Simon Microsoft Excel Programming 3 7th Aug 2003 02:50 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:05 PM.