When you say that Column A is "number format as: YYYYMM", it is unclear if 202211 is actually a number, or if it's just text, or if it's any date in November 2022 such as 11/1/2022. They are three COMPLETELY different things, and to get the month number from each would be completely different:
Book1 (version 2).xlsb |
---|
|
---|
| A | B |
---|
1 | 202211 | 11 |
---|
2 | 202211 | 11 |
---|
3 | 202211 | 11 |
---|
|
---|
Note that XL2BB is not preserving the Right/Left justification of Column A. Rows 1 and 3 are numbers and therefore Right justified automatically without any formatting applied manually, and row 2 is Text and therefore Left justified automatically without any formatting applied manually. With the exception of final reports, it's always best to NOT change any horizontal formatting since it's an easily spotted clue to possible problems. As long as I'm talking about formatting, NEVER use Merge & Center - it TOTALLY screws up a Worksheet's structure. Instead use Center Across Selection in the Horizontal Alignment format section.
p.s. I have no idea why VBA is even considered for this problem, nor do I comprehend what "not taking in consideration the variations from years" means or has to do with it.