Multiple dates in one cell automatically

tyr443

New Member
Joined
Mar 4, 2016
Messages
34
Office Version
  1. 365
Platform
  1. Windows
Hi all,

I want to fill a single cell with dates, spaced by 7 from the input date until the end of the month.
For example: I enter 02/01 (any format is fine) and the cell should fill with 02/01 09/01 16/01 23/01 30/01

Is this possible?

Thanks in advance for any help, sorry if this is a stupid question I am not very familiar with excel, I have been a MATLAB user until now.
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
Howsit dude, this should work:


Function DaysToEOM(dte As Date) As String
Dim s As String, n As Integer
n = Month(dte)
Do Until Not n = Month(dte)
s = s & Format(dte, "dd/mm") & " "
dte = DateAdd("d", 7, dte)
Loop
DaysToEOM = Trim(s)
End Function
 
Upvote 0
At the risk of sounding stupid.

How do I go about using this?
 
Upvote 0
Okay I think I worked it out but it doesn't seem to work. I get an error message every time.
 
Upvote 0
Okay I think I worked it out but it doesn't seem to work. I get an error message every time.

What error message are you getting?

Paste the script into a module in your Visual Basic window.
If you had a date in cell A1, and you wanted the string in cell B1, in cell B1 type: =DaysToEom(A1)
 
Upvote 0
#NAME? is the error.

In A1 I put 01/03

B1 I put: =DaysToEOM(A1)
 
Upvote 0
Hi,

You can test the following event macro ... (it goes in the Sheet module)

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address <> "$A$1" Then Exit Sub
Dim i As Integer
Dim max As Integer
max = Day(DateSerial(Year(Target), Month(Target) + 1, 1) - 1)
max = (max - Day(Target)) / 7
  i = 1
  Do
    Target.Offset(i, 0) = Target + 7 * i
    i = i + 1
  Loop Until i = max + 1
End Sub

HTH
 
Upvote 0

Forum statistics

Threads
1,223,719
Messages
6,174,089
Members
452,542
Latest member
Bricklin

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