Excel VBA remove subtotals and clear

816 views
Skip to first unread message

Larry D

unread,
Feb 22, 2007, 5:50:14 PM2/22/07
to excel vba
I am working on code in vba with Excel 2000 and Microsoft Windows
2000.

I have some code where I want to clear subtotals and
clear the contents from three tabs.

My code looks like this:

sheets("first").select
cells.select
selection.removesubtotal
selection.clearcontents

sheets("second").select
cells.select
selection.removesubtotal
selection.clearcontents
etc. etc.

How do I remove subtotals from all three tabs at the same time,
and how do I combine the lines of code to the least amount
of lines?

akhilesh

unread,
Apr 2, 2007, 1:17:39 AM4/2/07
to excel vba
Try this. [Note:Sheets 1 to 3 should be the desired tabs.]

Dim i As Integer
For i = 1 To 3
With Sheets(i).Cells
.RemoveSubtotal
.ClearContents
End With
Next i

Reply all
Reply to author
Forward
0 new messages