ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Delete Columns (https://www.excelbanter.com/excel-programming/416041-delete-columns.html)

BP

Delete Columns
 
I have a workbook with multiple worksheets. I want to delete certain columns
from each worksheet and then save as a new workbook.

Ex:
Worksheet 1: delete columns aa:ay
Worksheet 2: delete columns Z:BD



TomPl

Delete Columns
 
What is the question?

BP

Delete Columns
 
Sorry I am new to VB and I forgot the code:

I am trying to cycle thru the worksheets and remove certain columns.

I tried this and get a delete method of range class error

ActiveWorkbook.Worksheets("Sheet1").Select
Worksheet.Columns("AA:AY").Delete Shift:=xlToLeft

Any help would be appreciated.



--
BP


"TomPl" wrote:

What is the question?


Barb Reinhardt

Delete Columns
 
THis will delete it on every worksheet

Dim WS as Worksheet

For Each WS in ActiveWorkbook.Worksheets
WS.Columns("AA:AY").Delete
Next WS
--
HTH,
Barb Reinhardt



"BP" wrote:

Sorry I am new to VB and I forgot the code:

I am trying to cycle thru the worksheets and remove certain columns.

I tried this and get a delete method of range class error

ActiveWorkbook.Worksheets("Sheet1").Select
Worksheet.Columns("AA:AY").Delete Shift:=xlToLeft

Any help would be appreciated.



--
BP


"TomPl" wrote:

What is the question?


Barb Reinhardt

Delete Columns
 
ThisWorkbook.Worksheets("Sheet1").Columns("AA:AY") .Delete
ThisWorkbook.Worksheets("Sheet2").Columns("Z:BD"). Delete
--
HTH,
Barb Reinhardt



"BP" wrote:

I have a workbook with multiple worksheets. I want to delete certain columns
from each worksheet and then save as a new workbook.

Ex:
Worksheet 1: delete columns aa:ay
Worksheet 2: delete columns Z:BD



BP

Delete Columns
 
Thanks but I need to specify different columns ranges on different worksheets
--
BP


"Barb Reinhardt" wrote:

THis will delete it on every worksheet

Dim WS as Worksheet

For Each WS in ActiveWorkbook.Worksheets
WS.Columns("AA:AY").Delete
Next WS
--
HTH,
Barb Reinhardt



"BP" wrote:

Sorry I am new to VB and I forgot the code:

I am trying to cycle thru the worksheets and remove certain columns.

I tried this and get a delete method of range class error

ActiveWorkbook.Worksheets("Sheet1").Select
Worksheet.Columns("AA:AY").Delete Shift:=xlToLeft

Any help would be appreciated.



--
BP


"TomPl" wrote:

What is the question?


Barb Reinhardt

Delete Columns
 
It's very much the same. See other reply.
--
HTH,
Barb Reinhardt



"BP" wrote:

Thanks but I need to specify different columns ranges on different worksheets
--
BP


"Barb Reinhardt" wrote:

THis will delete it on every worksheet

Dim WS as Worksheet

For Each WS in ActiveWorkbook.Worksheets
WS.Columns("AA:AY").Delete
Next WS
--
HTH,
Barb Reinhardt



"BP" wrote:

Sorry I am new to VB and I forgot the code:

I am trying to cycle thru the worksheets and remove certain columns.

I tried this and get a delete method of range class error

ActiveWorkbook.Worksheets("Sheet1").Select
Worksheet.Columns("AA:AY").Delete Shift:=xlToLeft

Any help would be appreciated.



--
BP


"TomPl" wrote:

What is the question?


BP

Delete Columns
 
Thank You!!! That worked great
--
BP


"Barb Reinhardt" wrote:

ThisWorkbook.Worksheets("Sheet1").Columns("AA:AY") .Delete
ThisWorkbook.Worksheets("Sheet2").Columns("Z:BD"). Delete
--
HTH,
Barb Reinhardt



"BP" wrote:

I have a workbook with multiple worksheets. I want to delete certain columns
from each worksheet and then save as a new workbook.

Ex:
Worksheet 1: delete columns aa:ay
Worksheet 2: delete columns Z:BD




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

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