Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.newusers
|
|||
|
|||
how to find the operating syetem year in vba
Hello, i need to find out what the o.s. year is in vba so that i can delete
tab on a sheet. my sheet has several tab, some which i don't want to delete like "ledger" "2008" and the current year "2009" if i add extra years i would like to be able to delete years "2010" + i have some code wich add the years to my sheet which basicaly copys previous years and clears all the contents and renames it to the next year, in doing so it all so adds various totals to my "ledger" sheet. For Each sh In Sheets If sh.Name = "Ledger" Then GoTo skip If sh.Range("A1").Value NewYear Then _ NewYear = sh.Range("A1").Value skip: Next sh 'Select Lastest Year Nsh = CStr(NewYear) '''' change this year every year ''' If Nsh = "2008" Then End '''''''''''''''''''''''''''''''''''' Sheets(Nsh).Select 'Add and rename new sheet Worksheets(Nsh).Delete so its this line if Nsh = "2008" then end that i need to auto update. please help, thanks in advance |
#2
Posted to microsoft.public.excel.newusers
|
|||
|
|||
how to find the operating syetem year in vba
This will give you the current year:
Sub dural() NewYear = Year(Date) MsgBox (NewYear) End Sub Is this what you need? -- Gary''s Student - gsnu200829 "DarkNight" wrote: Hello, i need to find out what the o.s. year is in vba so that i can delete tab on a sheet. my sheet has several tab, some which i don't want to delete like "ledger" "2008" and the current year "2009" if i add extra years i would like to be able to delete years "2010" + i have some code wich add the years to my sheet which basicaly copys previous years and clears all the contents and renames it to the next year, in doing so it all so adds various totals to my "ledger" sheet. For Each sh In Sheets If sh.Name = "Ledger" Then GoTo skip If sh.Range("A1").Value NewYear Then _ NewYear = sh.Range("A1").Value skip: Next sh 'Select Lastest Year Nsh = CStr(NewYear) '''' change this year every year ''' If Nsh = "2008" Then End '''''''''''''''''''''''''''''''''''' Sheets(Nsh).Select 'Add and rename new sheet Worksheets(Nsh).Delete so its this line if Nsh = "2008" then end that i need to auto update. please help, thanks in advance |
#3
Posted to microsoft.public.excel.newusers
|
|||
|
|||
how to find the operating syetem year in vba
yes thank you, for some reason i always try to make things very complicated.
"Gary''s Student" wrote: This will give you the current year: Sub dural() NewYear = Year(Date) MsgBox (NewYear) End Sub Is this what you need? -- Gary''s Student - gsnu200829 "DarkNight" wrote: Hello, i need to find out what the o.s. year is in vba so that i can delete tab on a sheet. my sheet has several tab, some which i don't want to delete like "ledger" "2008" and the current year "2009" if i add extra years i would like to be able to delete years "2010" + i have some code wich add the years to my sheet which basicaly copys previous years and clears all the contents and renames it to the next year, in doing so it all so adds various totals to my "ledger" sheet. For Each sh In Sheets If sh.Name = "Ledger" Then GoTo skip If sh.Range("A1").Value NewYear Then _ NewYear = sh.Range("A1").Value skip: Next sh 'Select Lastest Year Nsh = CStr(NewYear) '''' change this year every year ''' If Nsh = "2008" Then End '''''''''''''''''''''''''''''''''''' Sheets(Nsh).Select 'Add and rename new sheet Worksheets(Nsh).Delete so its this line if Nsh = "2008" then end that i need to auto update. please help, thanks in advance |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How to find the year from a given date | Excel Discussion (Misc queries) | |||
Find Last Saturday of the Year | Excel Discussion (Misc queries) | |||
Use year and weeknr to find date?? | Excel Discussion (Misc queries) | |||
Find the first Sunday for a given year? | Excel Worksheet Functions | |||
want end of year balance sheet where to find it | Charts and Charting in Excel |