VBA increment number sequence based on 2 cell values

NormChart55

New Member
Joined
Feb 22, 2022
Messages
44
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

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
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,223,227
Messages
6,170,849
Members
452,361
Latest member
d3ad3y3

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