wolf.stalker
06-01-2008, 11:56 PM
hi all and thanks for any help you can add.
here is the basic idea of what i am doing.
1) i ask user for a date via input box (DateAns)
2) i then open up a workbook
<stuck>
3) i need to see if that worksheet exists and if not, create it. but i am stuck when trying to name wSheet the cStr(DateAns) value. i have tried everything i can think of...and i have read everything i can find on this :dunno
i have a bunch of comments of stuff i have tried but i removed them to try and keep this somewhat clean. anyone have any ideas?
Dim wSheet As Worksheet
Dim sAns As Date
Dim sNewName As String
sAns = InputBox("Please enter in date dd/mm/yy")
If Err.Number = 13 Then
MsgBox ("Please try again, you entered a bad date")
End
End If
'when i keyed in 9-9 for sAns is stores it as 9/9/2008 which is good.
sNewName = CStr(sAns) 'CStr(sAns) shows "9/9/2008" which is what i
'want but that value is NOT being stored in sNewName even though it's a 'string type...
wSheet.Text = sNewName 'sNewName shows correct value, but won't
'store in wSheet
' and of course the rest doesn't work .....
Set wSheet = Worksheets(sNewName)
If wSheet Is Nothing Then
Worksheets.Add(After:=Worksheets(Worksheets.Count)).Name = sNewName
End If
here is the basic idea of what i am doing.
1) i ask user for a date via input box (DateAns)
2) i then open up a workbook
<stuck>
3) i need to see if that worksheet exists and if not, create it. but i am stuck when trying to name wSheet the cStr(DateAns) value. i have tried everything i can think of...and i have read everything i can find on this :dunno
i have a bunch of comments of stuff i have tried but i removed them to try and keep this somewhat clean. anyone have any ideas?
Dim wSheet As Worksheet
Dim sAns As Date
Dim sNewName As String
sAns = InputBox("Please enter in date dd/mm/yy")
If Err.Number = 13 Then
MsgBox ("Please try again, you entered a bad date")
End
End If
'when i keyed in 9-9 for sAns is stores it as 9/9/2008 which is good.
sNewName = CStr(sAns) 'CStr(sAns) shows "9/9/2008" which is what i
'want but that value is NOT being stored in sNewName even though it's a 'string type...
wSheet.Text = sNewName 'sNewName shows correct value, but won't
'store in wSheet
' and of course the rest doesn't work .....
Set wSheet = Worksheets(sNewName)
If wSheet Is Nothing Then
Worksheets.Add(After:=Worksheets(Worksheets.Count)).Name = sNewName
End If