0

I have the following situation:

Current Data Structure

I would like have EACH initial Ref. Cell cell and its associated blank cells, for example A2:A7, updated so that its results in the following data structure:

Desired Data Structure

I have tried using formulas containing a combination of COUNT, COUNTBLANK, ROW() but have failed miserably in achieving the desired outcome.

Can you help?

2 Answers 2

2

In A2, formula copied down :

="1:"&COUNTA(B$2:B2)&":"&ROW(A1)-MATCH("zz",B$2:B2)+1

enter image description here

3
  • Hi @bosco_yip - that worked great. But I realised I did not fully detailed my scenario. After a few rows the "Ref Cell" changes so that the leading digit(s) are no longer '1'. I updated the original question with the correct details. Hopefully you can provide a solution to this updated scenario.
    – Ghulam
    Commented May 24, 2020 at 11:11
  • You can't remove your original tables and revised a new one. You can edit your post in adding more details to clarify your question but the original tables must be remained. Sorry I can't give you further help.
    – bosco_yip
    Commented May 24, 2020 at 12:00
  • I was unaware of the prohibition on altering the text of an original question. I was sincerely trying to clear up the ambiguity/confusion of my original question. I did not mean to cause any offence.
    – Ghulam
    Commented May 24, 2020 at 21:36
0

If with vba, maybe something like this ?

Sub Macro1()
For Each cell In Range("A2", Range("A" & Rows.Count).End(xlUp)).SpecialCells(xlCellTypeConstants)
If cell.End(xlDown).Row = Rows.Count Then Exit Sub
Set oEnd = cell.End(xlDown).Offset(-1, 0)
Set rngNum = cell
num = "'" & cell.Value & ":"
n = Range(cell, oEnd).Rows.Count
For i = 1 To n
rngNum.Value = num & i
Set rngNum = rngNum.Offset(1, 0)
Next i
Next cell
End Sub

But the weakness, the code will stop at the last row value in column A. For example based on your first image, the code will stop at 3:1 while you are expecting this 3:1 row will change to 3:1:1 and the next row value is 3:1:2

enter image description here

2
  • Thank you very much. This worked successfully on a +130K row file. Much appreciated. The GIF was a particularly nice touch :)
    – Ghulam
    Commented May 25, 2020 at 11:11
  • Glad I can help, Ghulam.
    – karma
    Commented May 25, 2020 at 15:10

Not the answer you're looking for? Browse other questions tagged or ask your own question.