VBA increment number sequence based on 2 cell values

NormChart55

New Member
Joined
Feb 22, 2022
Messages
42
Office Version
  1. 2016
Platform
  1. Windows
Hello - I am in need of a macro number sequence of files so that I can separate.

I have data headers in column C4-H4 and all the data will be located in C5:H50000 depending on how much data there is (that changes). I am needing to add a number sequence in Column B that goes in increment based on C (address) and H (reference) data. Example below. In the example below, I would want the sequence for first 3 lines to be 1/1/2 because line 3 the reference changes. Lines 4/5 would be 1/2 because the 5th line reference changes. Basically if reference changes compared to the address then it should be a new number sequence for that only so I can filter out the number of separate pages. I hope that makes sense. Thanks for any and all help you can provide.

AddressDatapartQuantityvendorReference
AAAXXX
AAAXXX
AAAXXY
BBBYYY
BBBYYX
 
That example does NOT look sorted to me.
I am thinking a two-level sort. Sort by Code field as the primary sort, and Reference field as the Secondary sort.
 
Upvote 0

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
Could the data be like this?
Book1
ABCDEFG
1CodeReferenceExpected sequence
2JYTXXX1
3JYTXXX1
4JYTXXY2
5JYTXXX?
Sheet3


if so, what should be the result of the last row?
 
Upvote 0
Does this come close?
NormChart55.xlsx
BCDEFGH
4SEQUENCECodeReference
51JYTXXX
61JYTXXX
72JYTXXY
81JGDXXX
91JGDXXX
102JGDXXY
112JGDXXY
123JGDXXX
131JZXXXX
141JZXXXX
151JZXXXX
161JYTXXX
172JYTXXY
183JYTXXZ
Sheet1
Cell Formulas
RangeFormula
B5:B18B5=IF(C5<>C4,1,IF(AND(C5=C4,H5=H4),B4,IF(AND(C5=C4,H5<>H4),B4+1)))
 
Upvote 0

Forum statistics

Threads
1,215,087
Messages
6,123,050
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