gravanoc
Active Member
- Joined
- Oct 20, 2015
- Messages
- 351
- Office Version
- 365
- Platform
- Windows
- Mobile
A window designer wants to number each window and use letters for each panel in that window. For example, he wants 4 windows: Window #1 has 2 panels, #2 has 4, #3 has 4, #4 has 8. This would produce the following series:
1A, 1B, 2A, 2B, 2C, 2D, 3A, 3B, 3C, 3D, 4A, 4B, 4C, 4D, 4E, 4F, 4G, 4H.
Though it's unlikely to exceed 26 panels, or even multiples of 26, I still want to be prepared for such. Using VBA to generate the number & letter combinations as follows:
The problem with the above code is that it will not know to increment the subsequent concatenated letters, and they will subsequently be AA, BB, CC, or AAA, BBB, CCC, and so on. The desired pattern would be AA, AB, AC, etc. Please assist me in that regard, thank you.
1A, 1B, 2A, 2B, 2C, 2D, 3A, 3B, 3C, 3D, 4A, 4B, 4C, 4D, 4E, 4F, 4G, 4H.
Though it's unlikely to exceed 26 panels, or even multiples of 26, I still want to be prepared for such. Using VBA to generate the number & letter combinations as follows:
VBA Code:
For i = 0 To windowRng.Rows.count - 1
panelCount(i) = panelRng.Cells(i + 1, 1).Value
For j = 0 To panelCount(i) - 1
quot = WorksheetFunction.RoundDown(j / 26, 0)
Debug.Assert (quot = 0)
prodRng.Cells(j + 1, 1).Value = i + 1
For x= 0 To quot
prodRng.Cells(j + 1, 2).Value = prodRng.Cells(j + 1, 2).Value & Chr(65 + (j Mod 26))
Next x
' More code not shown
Next j
Next i
The problem with the above code is that it will not know to increment the subsequent concatenated letters, and they will subsequently be AA, BB, CC, or AAA, BBB, CCC, and so on. The desired pattern would be AA, AB, AC, etc. Please assist me in that regard, thank you.