borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Previous Topic (Excel)Next Topic (transffering my database to excell??) New Topic New Poll Post Reply
AndreaVB Forum : VBA (Access, Excel, Word, ...) : Calculate correct week numbers
Poster Message
Guus
Level: Trainee

Registered: 22-03-2007
Posts: 3

icon Calculate correct week numbers

Hi All

I am looking for solution about to calculate correct week numbers.Now he make wrong week numbers. For example (must be week number 12 then he make a map week 11)

What a use is :

MyDate=Range("c4")
intweek=DateDiff("ww","01/01",My Date ,vbMonday)
strjaar=Year(MyDate)

My question is what must a change??

22-03-2007 at 06:33 PM
View Profile Send Email to User Show All Posts | Quote Reply
admin
Level: Administrator


Registered: 04-04-2002
Posts: 530
icon Re: Calculate correct week numbers

try this code:


Private Sub Worksheet_Change(ByVal Target As Excel.Range)
    On Error Resume Next
    Cells(1, 1) = DatePart("ww", Cells(1, 2))
End Sub


when you change the content of the cell (row 1, column 2) the number of week is displayed in cell (row 1, column 1)

____________________________
AndreaVB

23-03-2007 at 08:10 AM
View Profile Send Email to User Show All Posts Visit Homepage | Quote Reply
Guus
Level: Trainee

Registered: 22-03-2007
Posts: 3
icon Re: Calculate correct week numbers

quote:
admin wrote:
try this code:


Private Sub Worksheet_Change(ByVal Target As Excel.Range)
    On Error Resume Next
    Cells(1, 1) = DatePart("ww", Cells(1, 2))
End Sub


when you change the content of the cell (row 1, column 2) the number of week is displayed in cell (row 1, column 1)


Thanks for the reaction
25-03-2007 at 03:59 PM
View Profile Send Email to User Show All Posts | Quote Reply
AndreaVB Forum : VBA (Access, Excel, Word, ...) : Calculate correct week numbers
Previous Topic (Excel)Next Topic (transffering my database to excell??) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder