James Murrell
asked on
excel: create calendar worksheet based on column data
Hi hope you guys can help: I have a major headache and hopefully you guys will assist me.
i am using excel 2013 and i see i can insert calendar workeets but what i need is each month on its own worksheet with data added from two columns
the date data is
Date Evaluation Due
29/10/2014
29/10/2014
29/10/2014
29/10/2014
05/03/2015
08/05/2015
08/05/2015
08/05/2015
08/05/2015
15/05/2015
22/05/2015
25/05/2015
25/05/2015
26/06/2015
16/07/2015
17/07/2015
17/07/2015
17/07/2015
17/07/2015
17/07/2015
17/07/2015
17/07/2015
21/07/2015
23/07/2015
24/07/2015
29/07/2015
04/08/2015
the subject column is
Id
6933
6936
7950
6935
7515
7854
7855
7857
7856
7801
7942
7932
7861
8181
8213
8320
8315
8314
8319
8180
8201
8206
8132
7304
8353
8438
8261
Any ideas where to start...
i am using excel 2013 and i see i can insert calendar workeets but what i need is each month on its own worksheet with data added from two columns
the date data is
Date Evaluation Due
29/10/2014
29/10/2014
29/10/2014
29/10/2014
05/03/2015
08/05/2015
08/05/2015
08/05/2015
08/05/2015
15/05/2015
22/05/2015
25/05/2015
25/05/2015
26/06/2015
16/07/2015
17/07/2015
17/07/2015
17/07/2015
17/07/2015
17/07/2015
17/07/2015
17/07/2015
21/07/2015
23/07/2015
24/07/2015
29/07/2015
04/08/2015
the subject column is
Id
6933
6936
7950
6935
7515
7854
7855
7857
7856
7801
7942
7932
7861
8181
8213
8320
8315
8314
8319
8180
8201
8206
8132
7304
8353
8438
8261
Any ideas where to start...
Do you want some sort of planner, like a lookahead that tells you want needs doing week by week?
ASKER
yes as those columns get updated regularly
I have a five day lookahead with an input sheet for tasks to be entered and a calendar sheet that shows for the next 5 days ahead. It needs cleaning up though because I used for a company that I worked for.
I can post it later.
I can post it later.
ASKER
Sounds great: hopefully i change add more than the 5 days thanks Roy_Cox
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
sorry it does not work with my excel 2013 I enable marcos etc mcalform warning
It was developed in Excel 2013 and I have just opened it with Excel 2016.
Have you got the calendar icon in the same folder as the workbook? I'll open it with 2013 and get back to you
Have you got the calendar icon in the same folder as the workbook? I'll open it with 2013 and get back to you
Just downloaded the same files above and opened them on my work computer using Excel 2013 with no problems. You need to extract both files to the same folder
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I don't see why you need VBA to populate sheets when formulas will do the job.
@ Roy!
It depends on how much data you have and how will it grow in future as well.
It depends on how much data you have and how will it grow in future as well.
When doing something like this I always make the Calendar dynamic so that you don't pull through past data unless you require it.
ASKER
Roy_cox - must be because i am running windows 10: i get error with or with image... hey ho
sktneer - I like it , but look at macro i change values to y2 instead of a2 and ai instead of b2 and it crashes. could you comment in macro so I can learn?
sktneer - I like it , but look at macro i change values to y2 instead of a2 and ai instead of b2 and it crashes. could you comment in macro so I can learn?
Hi James,
Tried my best to comment the code to make it easy for you to change it as per your requirement.
If still have any doubt about any line of code, please let me know, I will try to clarify it.
Here is the code...
Tried my best to comment the code to make it easy for you to change it as per your requirement.
If still have any doubt about any line of code, please let me know, I will try to clarify it.
Here is the code...
Sub CreateMonthSheets()
Dim Sws As Worksheet, Dws As Worksheet
Dim Slr As Long
Dim Srng As Range, Cell As Range
Application.ScreenUpdating = False
Set Sws = Sheets("Data") 'Source Sheet, Data Sheet in this example
Slr = Sws.Cells(Rows.Count, 1).End(xlUp).Row 'Slr is the last row with data in Date Column A. Here 1 stands for col. A index number so if the Date column is B, 1 should be changed to 2.
Set Srng = Sws.Range("A2:A" & Slr) 'Srng assumes that the Dates are in col. A starting from Row2
For Each Cell In Srng
If Sws.Cells(Cell.Row, "AA") <> "Y" Then 'The code checks if the corresponding cell AA doesn't have a Y in it as when the row is copied first time the code puts a "Y" in the cell AA of that row, therefore it would not be copied next time.
On Error Resume Next
Set Dws = Sheets(Format(Cell, "mmm-yy")) 'This will be name of the month sheet and if the month sheet is not present it will produce an error and the control passes to the next IF block assuming Err<>0 and will create a new month sheet to have data
If Err <> 0 Then
Worksheets.Add(after:=Worksheets(Worksheets.Count)).Name = Format(Cell, "mmm-yy") 'Adds a worksheet and name it with the mmm-yy format of the date
Set Dws = ActiveSheet
Dws.Range("A1").Value = "Date Evaluation Due" 'The next few lines place the columns headers in the month sheets and format them
Dws.Range("B1").Value = "Id"
Dws.Range("A1:B1").Font.Bold = True
Dws.Range("A1:B1").HorizontalAlignment = xlCenter
End If
On Error GoTo 0
'1 in the below line is the column index number of col. A and 2 is the column index number of col. B, change them as per your requirement.
'Dws.Range("A" & Rows.Count).End(3)(2) will be the first empty cell in col. L, change it if you want to change the destination column
Sws.Range(Sws.Cells(Cell.Row, 1), Sws.Cells(Cell.Row, 2)).Copy Dws.Range("A" & Rows.Count).End(3)(2)
Sws.Cells(Cell.Row, "AA") = "Y" 'Once a row is copied to its relevant month sheet, the code puts a "Y" in the corresponding cell in col. AA to confirm that the row has been transferred to the months sheet.
Application.CutCopyMode = 0
Dws.UsedRange.Columns.AutoFit
End If
Next Cell
Sws.Activate
Application.ScreenUpdating = True
MsgBox "Data has been transferred to the Months Sheets successfully.", vbInformation, "Done!"
End Sub
You can also change the code as below.....
Similarly....
Slr = Sws.Cells(Rows.Count, "Y").End(xlUp).Row 'Slr is the last row with data in Date Column Y.
Set Srng = Sws.Range("Y2:Y" & Slr) 'Srng (Range) assumes that the Dates are in col. Y starting from Row2
Similarly....
Sws.Range(Sws.Cells(Cell.Row, "Y"), Sws.Cells(Cell.Row, "Z")).Copy Dws.Range("A" & Rows.Count).End(3)(2)
I am running Windows 10 with Office 2016 and the workbook works perfectly/ What error do you get exactly?.