Fill Property Let with function

silentwolf

Well-known Member
Joined
May 14, 2008
Messages
1,216
Office Version
  1. 2016
Hi guys,
I am just wondering how I could fill a property let with a function.

for example I got following function

Code:
Function KW_DIN(Datum As Date) As Integer
    '''geklaut ;o)
    ''von Christoph Kremer, Aachen
    'Berechnt die KW nach DIN 1355
    'http://www.office-loesung.de/fpost675805.php#675805

    Dim t&
    t = DateSerial(Year(Datum + (8 - Weekday(Datum)) Mod 7 - 3), 1, 1)
    KW_DIN = (Datum - t - 3 + (Weekday(t) + 1) Mod 7) \ 7 + 1
End Function

And I like to fill a property Let statement in a class module with this function

this I got in the Class module

Private m_KW as integer


Code:
Property Let Kalenderwoche(datKW As Date)
    m_KW = KW_DIN(datKW)
End Property

is this possible? Or is that not really how you should do that?

Thanks for your input!
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
Hi,

Is this what you want ? :

In the Class Module :
Code:
Private m_KW As Integer

Property Let Kalenderwoche(datKW As Date)
    
    Dim t&
    t = DateSerial(Year(datKW + (8 - Weekday(datKW)) Mod 7 - 3), 1, 1)
    m_KW = (datKW - t - 3 + (Weekday(t) + 1) Mod 7) \ 7 + 1


End Property
 
Upvote 0
Hi,
thanks Jaafar .. but I am still not really getting anywhere here..
I have a userform where I like to pick a date that should then fill the Kalenderwoche (Calendar Week) but somehow I am getting not the right answer..

I got this sub in the class module

Code:
Sub AddToTimeSheet()

    Range("G1").Value = Me.Mitarbeiter
    Range("B1").Value = Me.Kalenderwoche
 
    
End Sub

And a userform with a datepicker now I like after I click the ok button on the userform that my addToList sub of the class module fires..

Is this a bit clearer now?
 
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,159
Members
453,021
Latest member
Justyna P

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