Define excel formula or vba code

MSchädler

Board Regular
Joined
Apr 27, 2017
Messages
95
Hello there and I definitely need some help from someone to find a formula or a vba code for my column D.
Situation: I'm building a Excel sheet to act as a database and I want some automation.
In column A I have a formula for an incremental counter (starting from 1 counting up to 63655 when using, copy last row+paste below).
In column B I have different project names eg. Toronto, Montreal and so on.
In column C I have the adjacent opening date of each project.
In column D I want to insert the specific project-ID when several same project names occur. When it is a new project name I want to continue the sequence in Column A.

The database is similar to this
A
(counter)
B
(project name)
C
(opening date)
D
(project ID)
1Toronto03.15.20175
2Montreal15.01.20171
3Toronto20.04.20175
4Halifax10.06.20172
5Toronto01.01.20175
6XXX04.04.20163
7YYY08.04.20174

<tbody>
</tbody>

I'm now looking for a formula or a vba code to input in column D the appropriate project-ID.
The formula or vba code should do the following: Find in Column B every exact same project name (eg. Toronto), detect the oldest date of the project (column C), and then enter that row count from Column A in all cells with that same project name in column D.
Additional when opening a new project, the project ID (Column D) will be the next unused sequence of column A.

Can someone give me some suggestions on how to go about it?
Thanks in advance for your help.
 
Marc,

You are very welcome. I'm glad i could help in some way.

I've suggested a new way of identifying projects because adding new entries can change the already defined IDs. For example, considering the data sample from post 6, assume a new Halifax entry with an earlier date. This will happen:


A
B
C
D
1
Counter​
Project ID​
Opening Date​
Project Name​
2
1​
5​
15/03/2017​
Toronto​
3
2​
1​
15/01/2017​
Montreal​
4
3​
5​
20/04/2017​
Toronto​
5
4​
8​
10/06/2017​
Halifax​
6
5​
5​
01/01/2017​
Toronto​
7
6​
2​
04/04/2016​
XXX​
8
7​
3​
08/04/2017​
YYY​
9
8​
8​
02/01/2017​
Halifax​

<tbody>
</tbody>


Some projects would have a new ID. I am afraid that this may be confusing and does not seem to be a good practice.

Anyway, i hope you find a good solution.

Good luck!

M.
 
Upvote 0

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
Marc

It seems i misunderstood what you really want

Try this new version

A
B
C
D
1
Counter​
Project ID​
Opening Date​
Project Name​
2
1​
5​
15/03/2017​
Toronto​
3
2​
2​
15/01/2017​
Montreal​
4
3​
5​
20/04/2017​
Toronto​
5
4​
4​
10/06/2017​
Halifax​
6
5​
5​
01/01/2017​
Toronto​
7
6​
6​
04/04/2016​
XXX​
8
7​
7​
08/04/2017​
YYY​
9

<tbody>
</tbody>


Formula in A2 copied down
=IF(D2="","",N(A1)+1)

Formula in B2 copied down
=IF(A2="","",LOOKUP(1,0/FREQUENCY(1,(D$2:D$1000=D2)*(C$2:C$1000)),A$2:A$1000))

The formula assumes that every time a value (project) is entered in column D also a date is entered in column C and that dates in column C are real dates (numbers), not text.

M.
 
Upvote 0
Hello Marcelo
Many thanks for this additional Input.
I now have all the options that I need from you and from Peter to build my sheet and test it in real.
Again many thanks for your help!
Marc
 
Upvote 0

Forum statistics

Threads
1,214,599
Messages
6,120,449
Members
448,966
Latest member
DannyC96

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