พึ่งจัดทำ ข้อมูลในตาราง Excel โดยมีข้อมูลพระ สิ่งที่ต้องทำคือการคำนวณหา พรรษา ที่ผ่าน
ตอนนี้ใช้ VBA ด้วย =GetPansa(TODAY(),N8)

แต่อยากเปลี่ยนไปใช้สูตรธรรมดา จะได้ใช้นามสกุลธรรมดา ได้ เปิดบนมือถือได้
โค๊ดคือ
Function GetPansa(thinkDate As Date, startDate As Date)
Dim yearP As Double
yearP = Year(thinkDate) - Year(startDate)
If (Month(startDate) > 8) Then
GetPansa = yearP
If (Month(thinkDate) < 8) Then
GetPansa = yearP - 1
End If
End If
If (Month(startDate) <= 8) Then
GetPansa = yearP
If (Month(thinkDate) > 9) Then
GetPansa = yearP + 1
End If
End If
End Function
เวลาแปลงเป็นสูตร ต้องเขียนยังไงครับ
ถามผู้รู้ วิธีการเขียนสูตร excel โดยแปลงจาก VBA ครับ มือใหม่ขอความช่วยเหลือครับ
ตอนนี้ใช้ VBA ด้วย =GetPansa(TODAY(),N8)
แต่อยากเปลี่ยนไปใช้สูตรธรรมดา จะได้ใช้นามสกุลธรรมดา ได้ เปิดบนมือถือได้
โค๊ดคือ
Function GetPansa(thinkDate As Date, startDate As Date)
Dim yearP As Double
yearP = Year(thinkDate) - Year(startDate)
If (Month(startDate) > 8) Then
GetPansa = yearP
If (Month(thinkDate) < 8) Then
GetPansa = yearP - 1
End If
End If
If (Month(startDate) <= 8) Then
GetPansa = yearP
If (Month(thinkDate) > 9) Then
GetPansa = yearP + 1
End If
End If
End Function
เวลาแปลงเป็นสูตร ต้องเขียนยังไงครับ