Hi, I'm not that good with VBA but I've managed to do a procedure that is pretty complex (for me). I'm stuck right now with something it does.
I have a list of symbols in worksheet "orders" from A2 to A1000 for exemple.
I have this code below that create a sheet named like my symbols if I doesnt exist.
The problem is that as soon it finds a worksheet that is already named like my symbol, the procedure stops (which I don't want it to)...
for exemple..
if
A2 = C
A3 = BAC
A4 = GS
A5 = IBM
A5 = IBM
A6 = AAPL
A7 = YHOO
my macro will create a sheet named, C, BAC, IBM but will stops there (because there will already by a IBM sheets after the macro have created one from A5)...
How could I change my procedure for it to continue to A7 and also create a AAPL and YHOO sheets?
I have a list of symbols in worksheet "orders" from A2 to A1000 for exemple.
I have this code below that create a sheet named like my symbols if I doesnt exist.
The problem is that as soon it finds a worksheet that is already named like my symbol, the procedure stops (which I don't want it to)...
for exemple..
if
A2 = C
A3 = BAC
A4 = GS
A5 = IBM
A5 = IBM
A6 = AAPL
A7 = YHOO
my macro will create a sheet named, C, BAC, IBM but will stops there (because there will already by a IBM sheets after the macro have created one from A5)...
How could I change my procedure for it to continue to A7 and also create a AAPL and YHOO sheets?
Code:
Sub createlistworksheets()
Dim i As Integer
Dim z As Integer
Dim k As String
Dim y As Integer, blnFound As Boolean
blnFound = False
i = 2
z = Worksheets("orders").Cells(Rows.Count, "A").End(xlUp).Row
For i = 2 To z
k = Worksheets("orders").Cells(i, 1).Value
With thisworkbook
For y = 1 To .Sheets.Count
If .Sheets(y).Name = k Then
blnFound = True
Exit For
End If
Next y
If blnFound = False Then
.Sheets.Add
With ActiveSheet
.Name = k
End With
End If
End With
k = 0
Next i
End Sub