modify an array and get certain value also convert to month

elmnas

Board Regular
Joined
Feb 20, 2015
Messages
206
Dear VB Members,


I have got this problem,


I trying to sort out from the sheetname Companyname,Year,Month


The name is always written:
xxxxxxx_xxxx_xx
example

COMPANY_2015-05



I have made an array to try to filter the parts of the things.


by using these variables I can grep the parts of the name


see code below:


Code:
sub mytest()


For Each sht In ThisWorkbook.Worksheets
    mysheetname = sht.Name
        If sht.Name Like "Volvo Penta*" Then
         
        Myarr = Split(mysheetname, "_") ' seperate all words 

        myCompany = Myarr(0) 


        myyearandMonth = Myarr(1)
        myyear = Left(myyearandMonth, 4)
        mymonth = Right(myyearandMonth, 2)
        
        For i = 2 To ActiveSheet.UsedRange.SpecialCells(xlCellTypeLastCell).Row
        


		' I put all my code in here






        Next i
 


        End If
    Next sht
    


end sub


The problem is, when I can alert the last part of the combination (month)
I always recieve if there is a lower value than 10 I get 05.


so I need to delete the leading zero to get value "5"




Then I want to convert the number to the month number 5
so I recieve in a messagebox in this case (may)


Could someone help me out with a code?




Thank you in advance all VB Members




Cheers
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
My suggestion in your other thread will work fine with a text value of "05"
It will successfully convert "05" to "May"


But if you must, you can remove the leading zero with

mymonth = Val(Right(myyearandMonth, 2))
 
Last edited:
Upvote 0

Forum statistics

Threads
1,202,990
Messages
6,052,957
Members
444,621
Latest member
MIKOLAJ_R

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top