Upcoming Birthdays

campersand

New Member
Joined
Aug 14, 2014
Messages
5
Hi, I have a workbook with a bunch of info about customers on the first worksheet, and various statistics and graphs on subsequent worksheets. I've been trying to come up with a way to import certain info (name, birth date, address, age, etc) from the first worksheet into a "birthdays" worksheet, and have the birthdays worksheet only display customers who have a birthday in the next 3 days, or at least sort by birthday so that it's easy to find those with upcoming birthdays. I'd like it to automatically update when more customers are added to the main worksheet so that I don't have to enter each customer's info twice.

I've worked at this for hours without much progress but I'm admittedly not an excel wizard at all. Does anyone have a solution? Please let me know if you need more info as well. Thanks in advance. :)
 
Code:
Sub GetBirthdays()
Dim iOff As Long
Dim shDat As Worksheet, shRlt As Worksheet
Dim vBday, vName
Const kRESULT = "Result"
Const kPRIOR = 3   'days before bday
Const kCOLbday = 5   'the birthday column

Set shDat = ActiveSheet
Range("A2").Offset(0, kCOLbday - 1).Select
Sheets.Add
ActiveSheet.Name = kRESULT
Set shRlt = Sheets(kRESULT)
Range("A1").Value = "NAME"
Range("B1").Value = "BDAY"
Range("C1").Value = "DAYS"
Range("A2").Select
shDat.Activate

'assumes there is always data in the 1st column.
iOff = ActiveCell.Column - 1
While ActiveCell.Offset(0, -iOff).Text <> ""
   vBday = ActiveCell.Value
   If IsDate(vBday) Then
      If DateDiff("d", vBday, Date) <= kPRIOR Then
          vName = ActiveCell.Offset(0, -iOff).Text
             'post the birthday person
        shRlt.Activate
          ActiveCell.Value = vName
          ActiveCell.Offset(0, 1).Value = vBday
          ActiveCell.Offset(0, 2).Value = DateDiff("d", Date, vBday)
          
          ActiveCell.Offset(1, 0).Select    'next row
        shDat.Activate
      End If
   End If
   ActiveCell.Offset(1, 0).Select  'next row
Wend
shRlt.Activate
Set shDat = Nothing
Set shRlt = Nothing
End Sub
 
Upvote 0
Hey ranman, thanks so much for the code. Not being much of an excel guy, I don't think I'm utilizing it correctly. I created a new macro and ran it, which created a new worksheet called "Result" with "NAME", "BDAY" and "DAYS" in cells A1, B1 & C1. Not sure what to do next...
 
Upvote 0
Hey, thanks a lot for that. You got it closer than I could but it could use some more tweaking. The formula in the D column always returns "too late", because it's reading the year of the birth date and comparing it to today's date. That's something that I struggled with too.

It would be ideal if there was a way to either, A) Only show the birthdays within 3 days from today, or B) Sort by soonest birthday.
 
Upvote 0

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