RIght im totally lost,
my code below, as it has been given by someone working with me for review, i simply added a sheet name part as they recorded the whole thing and i did a quick tidy and added a quick enter date check at the start.
If Range("B2:C2").Text = "" Then 'B2:C2 is passed to A50 and and this cell is used to name the sheet.
MsgBox "Please enter Date in B2"
Exit Sub
Else
ActiveSheet.Unprotect
Sheets(1).Copy After:=Sheets(Sheets.Count)
ActiveSheet.Name = Format(Range("A50"), "dd-mm-yyyy")
Sheets(Sheets.Count).Protect
Sheets(1).Select
Selection.SpecialCells(xlCellTypeConstants, 1).Select
Selection.ClearContents
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:= _
False
End If
ActiveWorkbook.Save
I thought the check would have been something similar to
Dim wkshtnme as string
wkshtnme = Format(Range("A50"), "dd-mm-yyyy")
if worksheets.name = wkshtnme then 'here is where i thought there might be a straight forward line to solve this.
msgbox "this name exists, reenter name"
exit sub
else
'perform the bulk of the code above...
should i be using an error check or a do while loop?
i relatively new to vba and spend a good bit of time with vb.net but im a total novice...
so im happy for all advice as i like to try and get there myself in the end
Bookmarks