Deleting column in a worksheet that is not active worksheet

  • Thread starter Thread starter kansaskannan
  • Start date Start date
K

kansaskannan

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top