Hi
i need to add sheets and assign their names dynamically via variable. But i have to find a way to scan the names of all existing sheets in order to avoid duplicating Sheet names which would lead to execution error.
So i need a loop which would pass through the all sheet names, and in case there is the name which matches with the variable value it should concatenate say hyphen before the variable value (for example from var1=string1 to var1=-string1) and continue.
Thanks for any suggestion
i need to add sheets and assign their names dynamically via variable. But i have to find a way to scan the names of all existing sheets in order to avoid duplicating Sheet names which would lead to execution error.
So i need a loop which would pass through the all sheet names, and in case there is the name which matches with the variable value it should concatenate say hyphen before the variable value (for example from var1=string1 to var1=-string1) and continue.
Code:
Private Sub CommandButton2_Click()
Dim str As String
Dim strFirst10 As String
str = Worksheets("xyz").Cells(6, 3).Value
strFirst10 = Mid(str, 1, 10)
'creating a new excel worksheet called
'here i need the test if there is a sheet with the name as value of strFirst10
Sheets.Add.Name = strFirst10
End Sub
Thanks for any suggestion