user5603602
user5603602

Reputation:

VBA Activesheet

I'm trying to make a monthly evaluation.   I would like to read the sheet name, and then transform it into a date. The individual worksheets have the names January, February, etc. When I wanted to issue 0116, 0216, 0316 and get this save.

tabellenblatt = ActiveSheet.Name

Upvotes: 0

Views: 69

Answers (1)

iDevlop
iDevlop

Reputation: 25262

Looks like your problem is that you don't know how to transform month name into number ( but as string). Here is a solution (to be completed - I am not going to do all your work :)

Function getMonth(mname As String) As String
'returns month number as string, from month name. Eg: returns "02" for "Feb"
    Dim a()
    Dim i As Integer
    a = Array("jan", "feb", "mar", "apr", "...")
    i = Application.Match(mname, a, False)
    getMonth = Format$(i, "00")
End Function

Upvotes: 1

Related Questions