How to loop through cell to increment value on a different cell through VBA

lgovindan

New Member
Joined
Apr 4, 2020
Messages
5
Office Version
  1. 2016
Platform
  1. Windows
Hi
I am trying to create a VBA script.

I have Customer Number on Column A, Date on Column B and Seq on Column C.

I start with Seq 1 for the first customer and date. If the next row has the same customer and the same date, I put seq 1 on column 1.
On change of any date for the same customer, increment seq by 1.
If the customer changes, reset seq to 1 and now loop through the on change of date increment the seq for that customer number
Repeat this until the end of the worksheet.

Visual
Customer - Date - Seq
10 Apr-4-2016 1
10 Apr-4-2016 1
10 Apr-5-2016 2
10 Apr-6-2016 3
10 Apr-6-2016 3
10 Apr-6-2016 3
10 Apr-6-2016 3
10 Apr-7-2016 4
15 Jan-1-2017 1
15 Feb-8-2017 2

So on and so forth.



I have 225000 records and am trying to automate this to get it done.

Can you please provide me a VBA script that will do this.
 

jxb

Board Regular
Joined
Apr 19, 2007
Messages
132
Office Version
  1. 2010
Platform
  1. Windows
Just found time to actually try. The formula does not do exactly what you want. It kind of work but just realise that the sequence you are looking to establish is not what I understood the 1st time. So in simple term, forget about this approach :(


 

Some videos you may like

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"

Watch MrExcel Video

Forum statistics

Threads
1,127,676
Messages
5,626,215
Members
416,168
Latest member
tttt199623

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
Top