Macro to create dates

hip2b2

Board Regular
Joined
May 5, 2003
Messages
135
Office Version
  1. 2019
Platform
  1. Windows
I'm way out of my depth and and not even sure if a macro like this is reasonable (I'm sure it's possible, it just may be more effort than it's worth).

I have a series of days in column "A" (starting in row 3), 1, 4, 7, 3, 5, 22, 4, 8, 30, etc. The numbers are the day of the month.

In Column "J" (starting in row 3) is a list that looks like this - though much longer:
JANUARY
Margaret
Liam
Sam
Martin
FEBRUARY
Yuka
Paul
MARCH
Stephen
Tamara
etc.

Everyone listed under JANUARY is a Jan date, and everyone listed under FEBRUARY is a Feb date and so-forth;
Margaret is Jan 1
Liam is Jan 4
Sam is Jan 7
etc.

Yuka is Feb 3
Paul is Feb 5
etc.

Cell B1 contains the year.

What I would like is a Macro that cycles through the list and fills Column "B" (starting at Row 3) with the concatenated dates, so that:
Margaret is Jan 1 2018
Liam is Jan 4 2018
etc.

I will never run the macro where some of the dates are in one year and some are in another, so the year in call "B1" is valid for all the names in a run.

I think that covers it.

Interested in what can be done with this hodgepodge of stuff, and as always thanks for even looking.

hip
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
I have assumed that where there are Month names in column "J", the corresponding rows in column "A" are Blank. (The code need this to function)
Results in column "B".
Code:
[COLOR="Navy"]Sub[/COLOR] MG09May51
[COLOR="Navy"]Dim[/COLOR] Dn [COLOR="Navy"]As[/COLOR] Range, Mth [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]String,[/COLOR] R [COLOR="Navy"]As[/COLOR] Range, Dt [COLOR="Navy"]As[/COLOR] Date
 [COLOR="Navy"]For[/COLOR] [COLOR="Navy"]Each[/COLOR] Dn [COLOR="Navy"]In[/COLOR] Range("A:A").SpecialCells(xlCellTypeConstants).Areas
    Mth = Dn(1).Offset(-1, 9)
    Dt = "1/" & Mth & "/2019"

    [COLOR="Navy"]For[/COLOR] [COLOR="Navy"]Each[/COLOR] R [COLOR="Navy"]In[/COLOR] Dn
        R.Offset(, 1) = R.Offset(, 9) & " is " & MonthName(Month(Dt), True) & " " & R
    [COLOR="Navy"]Next[/COLOR] R
[COLOR="Navy"]Next[/COLOR] Dn
[COLOR="Navy"]End[/COLOR] [COLOR="Navy"]Sub[/COLOR]
Regards Mick
 
Upvote 0
Thanks Mick

Almost but not quite, what I got is:

Margaret is Jan 3
Liam is Jan 4
Sam is Jan 5
Martin is Jan 6

Yuka is Feb 4
Paul is Feb 5

Stephen is Mar 2
Tamara is Mar 3

What I require is (OK if it is formatted as text as this gets exported to a csv file):
Jan 3, 2019 (the year should come from Cell B1)
Jan 4, 2019
Jan 5, 2019
Jan 6, 2019

Feb 4, 2019
Feb 5, 2019

Mar 2, 2019
Mar 3, 2019


Thanks in advance
 
Upvote 0
Add to code as shown in red
Code:
 For Each R In Dn
R.Offset(, 1) = R.Offset(, 9) & " is " & MonthName(Month(Dt), True) & " " & R [COLOR="#FF0000"][B]& " " & [b1]
[/B][/COLOR]    Next R
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,888
Messages
6,175,219
Members
452,619
Latest member
Shiv1198

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