Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
deleting data but not formulae in multiple sheets | Excel Programming | |||
Deleting Duplicate Records across multiple sheets | Excel Worksheet Functions | |||
deleting columns on multiple sheets | Excel Discussion (Misc queries) | |||
Deleting multiple sheets | Excel Programming | |||
Deleting multiple Chart Tabs/sheets | Excel Programming |