run on each sheet after
Any suggestions?
Yes. Let's first be clear what this sub does. It reads backwards from Col 28
to Col 1 and if there is only 1 value in the column (Text or numeric) the
column is deleted and I assume that is what you want it do do.
Now returning to your very first post you want to do this on every sheet
AFTER sheet called IND_BRKDWN
So lets try again. Note as I advised in my first post, you have to know
where you are in the code hence I pass the variable X to the sub. Then when
we do the deletion we specify the sheet name by utilising the X variable with
the stetement
Set sht = Sheets(x)
Public x As Long
Sub nn()
For x = Sheets("IND_BRKDWN").Index + 1 To Worksheets.Count
Call AAA
Next
End Sub
Sub AAA()
Dim StartCol As Long
Dim EndCol As Long
Dim ColNdx As Long
Set sht = Sheets(x)
StartCol = 1 ' column A
EndCol = 28 ' column AB
For ColNdx = EndCol To StartCol Step -1
If Application.CountA(sht.Columns(ColNdx)) = 1 Then
sht.Columns(ColNdx).Delete
End If
Next ColNdx
End Sub
--
Mike
When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.
"J.W. Aldridge" wrote:
ok. i'm not sure why this isnt working, but i truly appreciate all the
help.
in lieu of Ryan's advice, I even tried putting the code in itself
instead of trying to call it.
Didn't work.
Any suggestions?
Sub AAA()
Dim StartCol As Long
Dim EndCol As Long
Dim ColNdx As Long
StartCol = 1 ' column A
EndCol = 28 ' column AB
For ColNdx = EndCol To StartCol Step -1
If Application.CountA(Columns(ColNdx)) = 1 Then
Columns(ColNdx).Delete
End If
Next ColNdx
End Sub
.
|