Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Deleting columns on multiple sheets

Hi,

I have a macro that attempts to delete column A on all sheets in the
workbook. What it currently does s delete all columns on the first sheet
(activesheet) only.

For Each ws In ActiveWorkbook.Worksheets
Columns("A:A").Select
Selection.Delete Shift:=xlToLeft
Next

Can anyone help to modify the code??
--
K Hogwood-Thompson
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 718
Default Deleting columns on multiple sheets

Try this:

Dim ws as Worksheet

For Each ws In ActiveWorkbook.Worksheets
ws.Columns("A").Delete Shift:=xlToLeft
Next

HTH
--
AP

"KHogwood-Thompson" a écrit
dans le message de news:
...
Hi,

I have a macro that attempts to delete column A on all sheets in the
workbook. What it currently does s delete all columns on the first sheet
(activesheet) only.

For Each ws In ActiveWorkbook.Worksheets
Columns("A:A").Select
Selection.Delete Shift:=xlToLeft
Next

Can anyone help to modify the code??
--
K Hogwood-Thompson



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Deleting columns on multiple sheets

You are iterating the worksheets but not giving your commands a reference to
it (hence, you keep deleting Column A on the active sheet, once per sheet in
the workbook). Also, whenever you see the selection of some range followed
by a method of that selection, you can almost always combine it into one
statement. Try this...

For Each ws In ActiveWorkbook.Worksheets
ws.Columns("A:A").Delete Shift:=xlToLeft
Next

Rick


"KHogwood-Thompson" wrote in
message ...
Hi,

I have a macro that attempts to delete column A on all sheets in the
workbook. What it currently does s delete all columns on the first sheet
(activesheet) only.

For Each ws In ActiveWorkbook.Worksheets
Columns("A:A").Select
Selection.Delete Shift:=xlToLeft
Next

Can anyone help to modify the code??
--
K Hogwood-Thompson


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Deleting columns on multiple sheets

Yes that works perfectly. Many thanks Ardus!
--
K Hogwood-Thompson


"Ardus Petus" wrote:

Try this:

Dim ws as Worksheet

For Each ws In ActiveWorkbook.Worksheets
ws.Columns("A").Delete Shift:=xlToLeft
Next

HTH
--
AP

"KHogwood-Thompson" a écrit
dans le message de news:
...
Hi,

I have a macro that attempts to delete column A on all sheets in the
workbook. What it currently does s delete all columns on the first sheet
(activesheet) only.

For Each ws In ActiveWorkbook.Worksheets
Columns("A:A").Select
Selection.Delete Shift:=xlToLeft
Next

Can anyone help to modify the code??
--
K Hogwood-Thompson




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default Deleting columns on multiple sheets

One way
Sub deletecolainallshts()
For i = 1 To Sheets.Count
Sheets(i).Columns("a").Delete
Next i
End Sub


--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"KHogwood-Thompson" wrote in
message ...
Hi,

I have a macro that attempts to delete column A on all sheets in the
workbook. What it currently does s delete all columns on the first sheet
(activesheet) only.

For Each ws In ActiveWorkbook.Worksheets
Columns("A:A").Select
Selection.Delete Shift:=xlToLeft
Next

Can anyone help to modify the code??
--
K Hogwood-Thompson


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
deleting data but not formulae in multiple sheets Terry Freedman Excel Programming 5 July 17th 08 12:54 AM
Deleting Duplicate Records across multiple sheets saschmeling Excel Worksheet Functions 1 May 29th 08 03:55 PM
deleting columns on multiple sheets school counselor Excel Discussion (Misc queries) 4 May 25th 08 10:22 PM
Deleting multiple sheets hshayh0rn Excel Programming 12 April 11th 06 06:52 PM
Deleting multiple Chart Tabs/sheets CLR Excel Programming 13 March 6th 05 03:58 AM


All times are GMT +1. The time now is 10:13 AM.

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

About Us

"It's about Microsoft Excel"