Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 15
Default 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   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 11,058
Default 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   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 15
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to find the year from a given date User Excel Discussion (Misc queries) 3 December 29th 08 12:50 PM
Find Last Saturday of the Year jlclyde Excel Discussion (Misc queries) 23 March 18th 08 01:14 PM
Use year and weeknr to find date?? ElFrodo Excel Discussion (Misc queries) 2 February 5th 07 04:19 AM
Find the first Sunday for a given year? Eutrapelia Excel Worksheet Functions 2 January 20th 06 06:07 PM
want end of year balance sheet where to find it chinajasmin5569 Charts and Charting in Excel 1 February 2nd 05 01:15 AM


All times are GMT +1. The time now is 10:46 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"