Hi,
I am relatively new to VBA and so far I love it.
I am trying to write a macro that will create sheets and fill data into them. I would like for my macro to create the sheets if they do not exist or, if they do exist, then move onto the next steps.
So far I have this code..
This code works if the first "AssemblyType" sheet does not exist, if it does and the next sheets do not exist, it does not create them.
I am sure there is an obvious flaw, as I am very new.
Also, I would prefer to not use Dim yet, I plan to learn that soon, once I get a better understanding of the basics.
Thanks.
I am relatively new to VBA and so far I love it.
I am trying to write a macro that will create sheets and fill data into them. I would like for my macro to create the sheets if they do not exist or, if they do exist, then move onto the next steps.
So far I have this code..
Code:
For i = 1 To Worksheets.Count
If Worksheets(i).Name = "AssemblyType" Then
exists = True
End If
Next i
If Not exists Then
Sheets.Add(After:=Sheets(Sheets.Count)).Name = "AssemblyType"
End If
For i = 1 To Worksheets.Count
If Worksheets(i).Name = "ParentChild" Then
exists = True
End If
Next i
If Not exists Then
Sheets.Add(After:=Sheets(Sheets.Count)).Name = "ParentChild"
End If
For i = 1 To Worksheets.Count
If Worksheets(i).Name = "OutputData" Then
exists = True
End If
Next i
If Not exists Then
Sheets.Add(After:=Sheets(Sheets.Count)).Name = "OutputData"
End If
This code works if the first "AssemblyType" sheet does not exist, if it does and the next sheets do not exist, it does not create them.
I am sure there is an obvious flaw, as I am very new.
Also, I would prefer to not use Dim yet, I plan to learn that soon, once I get a better understanding of the basics.
Thanks.