Macro to create dates

hip2b2

Board Regular
Joined
May 5, 2003
Messages
73
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
 

MickG

MrExcel MVP
Joined
Jan 9, 2008
Messages
14,841
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
 

hip2b2

Board Regular
Joined
May 5, 2003
Messages
73
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
 

MickG

MrExcel MVP
Joined
Jan 9, 2008
Messages
14,841
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:

Forum statistics

Threads
1,081,976
Messages
5,362,513
Members
400,679
Latest member
alecalec202

Some videos you may like

This Week's Hot Topics

  • populate from drop list with multiple tables
    Hi All, i have a drop list that displays data, what i want is when i select one of those from the list to populate text from different tables on...
  • Find list of words from sheet2 in sheet1 before a comma and extract text vba
    Hi Friends, Trying to find the solution on my task. But did not find suitable one to the need. Here is my query and sample file with details...
  • Dynamic Formula entry - VBA code sought
    Hello, really hope one of you experts can help with this - i've spent hours on this and getting no-where. .I have a set of data (more rows than...
  • Listbox Header
    Have a named range called "AccidentsHeader" Within my code I have: [CODE]Private Sub CommandButton1_Click() ListBox1.RowSource =...
  • Complex Heat Map using conditional formatting
    Good day excel world. I have a concern. Below link have a list of countries that carries each country unique data. [URL...
  • Conditional formatting
    Hi good morning, hope you can help me please, I have cells P4:P54 and if this cell is equal to 1 then i want row O to say "Fully Utilised" and to...
Top