Auto generate duplicate Dates

pwill

Active Member
Joined
Nov 22, 2015
Messages
406
Hi can anyone help with a formula or macro?

I have Headers in cells "A1"(Date) "B1"(Seq) and "L1"(Next) Sheet1

"B2:B" has a sequence of numbers
"L2" auto generates dates
"L3" has either the letter A or B

I want to auto generate duplicate dates in ("A2:A") down to the last row in column B based on data in cells "L2" and "L3"

ie if "L2" generates the date 01/02/18 and "L3" has the letter A then column A would generate dates as follows


ABCDEEFGHIJKLM
1DateSeq









Next
201/02/18
1









01/02/18

302/02/18
2









A
402/02/18
3











503/02/18
4











603/02/18
5











704/02/18
6











804/02/18
7











905/02/18
8











1005/02/18
9











1106/02/18
10











1206/02/18
11











1307/02/18
12











14
07/02/18
13












15














<colgroup><col style="width:48pt" width="64" span="15"> </colgroup><tbody>
</tbody>

ie if "L2" generates the date 01/02/18 and "L3" has the letter B then column A would generate dates as follows


ABCDEEFGHIJKLM
1DateSeq









Next
202/02/18
1









01/02/18

302/02/18
2









B
403/02/18
3











503/02/18
4











604/02/18
5











704/02/18
6











805/02/18
7











905/02/18
8











1006/02/18
9











1106/02/18
10











1207/02/18
11











1307/02/18
12











14













15














<colgroup><col style="width:48pt" width="64" span="15"> </colgroup><tbody>
</tbody>

Any help would be apprieciated

Regards

pwill
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
Just thought I would add that although they look very similar the difference between A and B is, if L3 has A the date in column A starts with the same date as L2 but only once as this would be added to data on sheet2 giving the duplicacate when added.

If L3 has B the dates start duplicating from the next day after the date in L2

hope that makes sense?

regards
 
Last edited:
Upvote 0
Hi can anyone help with a formula or macro?

I have Headers in cells "A1"(Date) "B1"(Seq) and "L1"(Next) Sheet1

"B2:B" has a sequence of numbers
"L2" auto generates dates
"L3" has either the letter A or B

I want to auto generate duplicate dates in ("A2:A") down to the last row in column B based on data in cells "L2" and "L3"

ie if "L2" generates the date 01/02/18 and "L3" has the letter A then column A would generate dates as follows


ABCDEEFGHIJKLM
1DateSeq









Next
201/02/181









01/02/18
302/02/182









A
402/02/183











503/02/184











603/02/185











704/02/186











804/02/187











905/02/188











1005/02/189











1106/02/1810











1206/02/1811











1307/02/1812











1407/02/18
13












15














<tbody>
</tbody>

ie if "L2" generates the date 01/02/18 and "L3" has the letter B then column A would generate dates as follows


ABCDEEFGHIJKLM
1DateSeq









Next
202/02/181









01/02/18
302/02/182









B
403/02/183











503/02/184











604/02/185











704/02/186











805/02/187











905/02/188











1006/02/189











1106/02/1810











1207/02/1811











1307/02/1812











14













15














<tbody>
</tbody>

Any help would be apprieciated

Regards

pwill



Help needed please, I have tried to write my own code if "L3" has the letter A but I don't know how to loop it through to the last row for me?

Code:
Sub autodates()

Dim dt As Date
Dim dtA As String
Dim dtB As String
Dim lrow As Long

lrow = Cells(Rows.Count, "B").End(xlUp).Row

dt = Range("L2").Value
dtA = Range("L3").Value
dtB = Range("L3").Value

r = 1
r = r + 1
If dtA = "A" Then

Cells(r, "A").Value = dt
Cells(r + 1, "A").Value = dt + 1
Cells(r + 2, "A").Value = dt + 1
Cells(r + 3, "A").Value = dt + 2
Cells(r + 4, "A").Value = dt + 2
Cells(r + 5, "A").Value = dt + 3
Cells(r + 6, "A").Value = dt + 3

End If

End Sub

can anyone help?

regards

pwill
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,086
Messages
6,123,040
Members
449,092
Latest member
ikke

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