I currently have 2 columns:
- Parent Measurement - value should be the top/parent value in the measurement column that isn't indented
- Measurement - Nonindented values are parents, indented values belong under unindented value.
Currently I'm able to read if a certain cell under the measurement column is indented and then I put a 1 to flag it. However, instead of assigning a 1, how can assign the value of the parent measurement that isn't indented?
The picture is how I would like the end result to look like, the second one is how I currently my code does it. Thank you!
Set rngCol = wssc.Range("DRT_Table[Measurement]")
For Each cl In rngCol
If cl.IndentLevel = 2 Then
cl.Offset(0, -1).Value = "1" '<--This is the part I need help with'
End If
Next cl
CodePudding user response:
Try something like this - if cl
doesn't have an IndentLevel
of 2, then assign its value to a variable parentMeasure
, otherwise assign parentMeasure
to cl.Offset(0, -1)
.
For Each cl In rngCol
Dim parentMeasure As String
If cl.IndentLevel = 2 Then
cl.Offset(0, -1).Value = parentMeasure
Else
parentMeasure = cl.Value
End If
Next