Extract Date from Last Number

muhammad susanto

Well-known Member
Joined
Jan 8, 2013
Messages
2,077
Office Version
  1. 365
  2. 2021
Platform
  1. Windows
hi all..
how to extract or pull number from last date number
note use vba/macro
Book1
FG
2date (dd-mm-yyyy)extract number
323/10/20200
409/12/20166
501/01/20177
623/10/19955
Sheet1


thank in advance
.sst
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
Hi, using formula:

Queries-2.xlsm
AB
1date (dd-mm-yyyy)extract number
223-10-20200
309-12-20166
401-01-20177
523-10-19955
6
Sheet1
Cell Formulas
RangeFormula
B2:B5B2=RIGHT(YEAR(A2),1)
 
Upvote 0
Solution
Using Macro:
VBA Code:
Sub showLastDigit()
   With Sheets("Sheet1")
    For rowno = 2 To .Cells(Rows.Count, 1).End(xlUp).Row
        .Cells(rowno, 3) = Right(Year(.Cells(rowno, 1)), 1)
    Next
End With
End Sub
 
Upvote 0
Another option without the loop
VBA Code:
Sub muhammad()
   With Range("G3:G" & Range("F" & Rows.Count).End(xlUp).Row)
      .Value = Evaluate("if({1},right(year(" & .Offset(, -1).Address & ")))")
   End With
End Sub
 
Upvote 0
hi Saurabhj & Fluff ...thank you very much..
all that worked great!!
sorry i missing it :
note use macro should be don't use...
 
Upvote 0
Glad we could help & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,573
Messages
6,120,310
Members
448,955
Latest member
Dreamz high

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