month name

R

RobcPettit

Hi, using an input box in vba, were a date ia added, I want to name
worksheets based on the month of the given date. For example if
21/6/08 was entered, then my worksheet will be called June. How do I
get the information using vba.
Regards Robert
 
H

Harald Staff

Hi Robert

Sub test()
Dim D As Date
D = DateSerial(2008, 6, 21)
MsgBox D
MsgBox Format$(D, "mmmm")
End Sub

Best wishes Harald
 
F

FSt1

hi
something like this might work
Sub robcpettit()
Dim m As String
Dim ib As String
ib = InputBox("enter date")
m = WorksheetFunction.Text(ib, "mmmm")
Sheets("sheet1").Name = m
End Sub

regards
FSt1
 
F

FSt1

hi
if sheets("sheet1").name = m isn't what you want(sheet specific). try this..
activesheet.name = m

regards
FSt1
 
G

Gary Keramidas

here's one way:

Sub test()
Dim dt As Date
dt = InputBox("Enter Date")
Worksheets("sheet1").Name = MonthName(Month(dt))
End Sub

or

Sub test()
Dim dt As Date
dt = InputBox("Enter Date")
ActiveSheet.Name = MonthName(Month(dt))
End Sub
 
R

RobcPettit

here's one way:

Sub test()
Dim dt As Date
dt = InputBox("Enter Date")
Worksheets("sheet1").Name = MonthName(Month(dt))
End Sub

or

Sub test()
Dim dt As Date
dt = InputBox("Enter Date")
ActiveSheet.Name = MonthName(Month(dt))
End Sub

--

Gary






- Show quoted text -

Thanks everybody, thats helped me get the results I was looking for.
Regards Robert
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top