Macro to paste info if it is between certain dates

ronanbaker1

Board Regular
Joined
Nov 15, 2012
Messages
76
Hi Guys,

I have a macro that could have any date from 2014 to present. What I am looking for is

if the date was before 2014 then....
Or if the date was between 01/01/15 - 03/31/15 then..
Or if the date was between 04/01/15 - 06/30/15 then..
Or if the date was between 07/01/15 - 09/31/15 then..
Or if the date was between 10/01/15 - 12/31/15 then..


Any suggestions? I'm good with If formulas just not good with the dates bit.
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Hi,
Pretty hard to get too detailed with only the example data provided. I'm sure whatever you're really doing is not quite as simple as the question being asked. (It seldom is.) ;)
Excel just views date as numbers, so it's just a simple "If one is more than, or less than the other" kind of thing.
Say all your dates were on the active sheet, and you have 1/1/2015 in cell A1, 3/1/2015 in cell B1 and 1/18/2015 in cell D1.
You're trying to determine if the date in cell D1 is between the dates in cells A1 & B1.
A simple code example might look something like this.
Code:
If [D1] > [A1] And [D1] < [B1] Then MsgBox [D1].Value & " is between " & [A1].Value & " and " & [B1].Value

Does that help get you pointed on the direction you're looking to go?
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,959
Messages
6,122,476
Members
449,087
Latest member
RExcelSearch

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