Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have the following code but can't get it to work. Essentially, when the
macro is run a new sheet is made and the new name assigned is the day that the macro is run. I want it to stop, not make the new sheet and close the UserForm if a sheet of that name already exists (along with the msgbox explaining what happend). I assume that the problem is common from different data types and have tried CInt, CVar, etc... with no luck. Where am I going wrong. Thanks in advance for any assistance. Brad K Private Sub cbOK_Click() Dim i As Integer Dim j As Integer Dim xDay As Integer Dim xMonth As Integer Dim xYear As Integer i = Worksheets.Count For j = 1 To i If Worksheets(j).Name = Day(Calendar1.Value) Then MsgBox "The date you have chosen already exists as a sheet." Unload Me End If Next j Worksheets("Template").Copy Befo=Worksheets(i) xYear = Year(Calendar1.Value) xMonth = Month(Calendar1.Value) xDay = Day(Calendar1.Value) Cells(7, 9) = xMonth & "/" & xYear Cells(7, 9).NumberFormat = "mmmm/yy" Worksheets(i).Name = xDay Unload Me End Sub |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
VBA to stop XL from adding the Path Sring to Sheet-to-Sheet Links | Excel Discussion (Misc queries) | |||
How can I stop excel from automatically making hyperlinks | Excel Discussion (Misc queries) | |||
How do I stop Excel from making copies of files? | Excel Discussion (Misc queries) | |||
stop automatically making email address | Excel Discussion (Misc queries) | |||
what is the keys to stop recording, i cant press it when making a. | Excel Discussion (Misc queries) |