Khan kashaf
New Member
- Joined
- May 11, 2021
- Messages
- 14
- Office Version
- 2019
- 2016
- 2010
- Platform
- Windows
- MacOS
- Mobile
- Web
Hello pls help me .. I have 2 sheets source and output.. in source I have date of birth .. now I have to calculate age and print in output sheet through array ..
VBA Code:
ActiveWorkbook.Sheets("Source").Select
Range("A1:D" & last).Value = arr
'2nd part
For i = LBound(arr, 1) To UBound(arr, 1)
count = count + 1
ReDim Preserve arr2(1 To last, 1 To 3)
arr2(count, 1) = Trim(arr(i, 1))
arr2(count, 2) = Trim(arr(i, 2))
ActiveWorkbook.Sheets("Output").Select
Sheets("Output").Columns("A:C").AutoFit
Range("A1:C" & count).Value = arr2
Next
ActiveWorkbook.Sheets("Source").Select
For i = LBound(arr, 1) To UBound(arr, 1)
d1 = Day(Date)
d2 = Day(b)
m1 = Month(Date)
m2 = Month(b)
y1 = Year(Date)
y2 = Year(b)
If m1 > m2 Then
d = y1 - y2
ElseIf (m1 >= m2 And d1 >= d2) Then
d = y1 - y2
Else: d = y1 - y2
End If
Sheets("output").Range("C").Value = d & "year"
count = count + 1
ReDim Preserve arr2(1 To last, 1 To 3)
arr2(count, 1) = Trim(arr(i, 1))
arr2(count, 2) = Trim(arr(i, 2))
Next
Last edited by a moderator: