A quick help needed from Macro expert !

pratikravani

Board Regular
Joined
Sep 7, 2011
Messages
60
Hi,

I have a database of some hundreds of ppl with their important dates. E.g. One of the columns I have is for their birthdates. But the prob is: The dates are stored with their birth years so if I try to run macro while equalling the list of dates with the DATE function, it wont run. I need to segregate only the month and the date from the birthdate while omitting birthyear so that I come to know whose birthdays fall in the near future.

I guess month(date) may work but trying hard...unable to solve.

If anyone can....

Thanks..
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
Hi thanks for the help...but this is not what I'm looking for. This is to be used in the workbook and not for Macro. And this (mm/dd/yy) is only to bring out the months/date/year as per your need.

Here the need is: Worksheet column is filled with dates having different years, I want to neglect years while I run a loop in that column using Macro. And in that loop, I want to avoid years and just want to take into account date and month. How to do that in VBA?
 
Upvote 0
If you have the dates as full Excel dates then using the Month function in VBA will tell you what the month is (1 to 12):

Code:
 MsgBox "Month number is " & Month(Range("A1").Value)

for example. What else do you want to do with it?
 
Upvote 0
I have tried the same thing...

i.e. If Month(Sheets("DB").Range("D" & i).Value) = Month(Date) Then....

This works, but This way I can only fetch the dates falling in the same month. Along with the month I also need "date" to be equalized.

Thanks anyways...
 
Upvote 0
Well, you have a Day() function available too:

Code:
If Day(Range("D1").Value) = Day(Date) And Month(Range("D1").Value = Month(Date) Then

You could convert to a text string to make for easier (shorter code) comparison:

Code:
If Format(Range("D1").Value,"mmmdd") = Format(Date,"mmmdd") Then
 
Upvote 0
Thanks buddy...Prob got solved with that day function which I used and made it work the way I wanted. Was unaware of that.

Thanks a ton.

:)
 
Upvote 0

Forum statistics

Threads
1,224,597
Messages
6,179,808
Members
452,944
Latest member
2558216095

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