ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Deleting column in a worksheet that is not active worksheet (https://www.excelbanter.com/excel-programming/398647-deleting-column-worksheet-not-active-worksheet.html)

[email protected]

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.


Jim Thomlinson

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.



dan dungan

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.




[email protected]

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.





All times are GMT +1. The time now is 01:55 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com