Hi I have this sheet, where I wan't it to add sheets based on a pre defined range.
So fare so good, I got that working, but if I come back to the sheet and add date within the range, it comes up with an error.
It tryes to make a sheet that's allready there, what I need it to do is skip sheets allready present.
Sub OpretFanerEfterListe()
Dim ws As Worksheet, Ct As Long, c As Range
Set ws = Worksheets("Skabelon")
Application.ScreenUpdating = False
For Each c In Sheets("Forside").Range("A6:A29")
If c.Value <> "" Then
ws.Copy after:=Sheets(Sheets.Count)
ActiveSheet.Name = c.Value
Ct = Ct + 1
End If
Next c
If Ct > 0 Then
MsgBox Ct & " Nye aftale sedler oprettet"
Else
MsgBox "Der er ingen aftalesedler at oprette"
End If
Application.ScreenUpdating = True
End Sub
The range I work with is A6:A29, so is I set the Datavilidation field (B2) to 5 i makes a list within the range of 1-5, and i hit the button it works and i get 4 new sheets names 2-4 no problem there.
But if I come back and change B2 to lets say 7, it updates the list to 1-7 that works, but when i hit the button to create sheets the error occurs.
I cant seem to figure out what code to add to make it skip allready exixting sheets and just make the uniqe once.