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

Signature
K Hogwood-Thompson
Ardus Petus - 18 Aug 2008 09:42 GMT
Try this:
Dim ws as Worksheet
For Each ws In ActiveWorkbook.Worksheets
ws.Columns("A").Delete Shift:=xlToLeft
Next
HTH
--
AP
"KHogwood-Thompson" <KHogwoodThompson@discussions.microsoft.com> a écrit
dans le message de news:
3084AD7E-BDFB-40FC-BA5B-904F9431F140@microsoft.com...
> Hi,
>
[quoted text clipped - 8 lines]
>
> Can anyone help to modify the code??
KHogwood-Thompson - 18 Aug 2008 09:53 GMT
Yes that works perfectly. Many thanks Ardus!

Signature
K Hogwood-Thompson
> Try this:
>
[quoted text clipped - 23 lines]
> >
> > Can anyone help to modify the code??
Rick Rothstein (MVP - VB) - 18 Aug 2008 09:49 GMT
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
> Hi,
>
[quoted text clipped - 8 lines]
>
> Can anyone help to modify the code??
Don Guillett - 18 Aug 2008 13:28 GMT
One way
Sub deletecolainallshts()
For i = 1 To Sheets.Count
Sheets(i).Columns("a").Delete
Next i
End Sub

Signature
Don Guillett
Microsoft MVP Excel
SalesAid Software
dguillett1@austin.rr.com
> Hi,
>
[quoted text clipped - 8 lines]
>
> Can anyone help to modify the code??