Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to conditionally create a column of summary?

Status
Not open for further replies.

feipezi

IS-IT--Management
Aug 10, 2006
316
0
0
US
Hello folks,
Long time no talk. Hope you're all doing well.

I have a workbook with a few tabs. I want to check first to see if the summary column is already there or not. If it is there, then exit sub or run another sub to create that column. The code is like the following:

Sub FindNCO()
Range(Cells(1, 1), Cells(Cells(1, 1).CurrentRegion.Row, Cells(1, 1).CurrentRegion.Columns.Count)).Select
For Each c In Selection
If InStr(c.Value, "Net Charge Off") Then
Exit Sub
Else:
Exit For
GoTo label
End If
Next
label: Call RunAllTabs
End Sub

But what I have is: if the column is there, the same column will be created again because the 'GoTo label' statements.
Any idea how to fix the bug to get what I want?
Thanks in advance.

Sub RunAllTabs()
For Each st In Worksheets
st.Activate
Call NetChargeOff
ActiveSheet.UsedRange.EntireColumn.AutoFit
Next
End Sub
 
You may want to post your question in forum707
This is VB5/6 classic, different 'animal' that Excel's VBA


---- Andy

There is a great need for a sarcasm font.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top