Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Deleting column in a worksheet that is not active worksheet


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.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Deleting column in a worksheet that is not active worksheet

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


" 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.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 411
Default Deleting column in a worksheet that is not active worksheet

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, 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.



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Deleting column in a worksheet that is not active worksheet

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, 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
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Basic Question - How do I return the worksheet number of the active worksheet? Regnab Excel Programming 2 May 17th 06 03:02 AM
Active cell, row, column, worksheet, etc sip8316 Excel Programming 2 June 6th 05 02:29 PM
Report All Column Widths In Active Worksheet - Corrected DataFreakFromUtah Excel Programming 1 July 22nd 04 01:13 PM
Report All Column Widths In Active Worksheet - an example DataFreakFromUtah Excel Programming 2 July 21st 04 06:09 PM
macro to apply worksheet event to active worksheet Paul Simon[_2_] Excel Programming 3 August 7th 03 02:50 AM


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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"