Hi,
I have made a simple macro that splits the following data
red blue yellow
1 2 2
3 3 1
into...
red blue yellow
1 2 2
red blue yellow
3 3 1
The problem is that I want it to work out how many columns I have using a loop so that I can avoid using the repeat coding. e.g Head_1 = Range...
I think should be easy but I am pulling my hair out! Thank you to anyone who helps out
Code:
Dim c As Range, rng
Dim Header_1 As String
Dim Header_2 As String
Dim Header_3 As String
Header_1 = Range("a1").Value
Header_2 = Range("b1").Value
Header_3 = Range("c1").Value
Set rng = Range("b2:b" & Range("b65536").End(xlUp).Row)
For Each c In rng
If c.Value <> "" And c.Offset(1, 0).Value <> 0 Then
If c.Value = c.Offset(1, 0).Value Then
Else
For i = 1 To 2 Step 1
c.Offset(1, 0).EntireRow.Insert shift:=xlDown
Next i
End If
End If
Next c
For Each c In rng
If c.Value = "" Then
c.Offset(1, -1) = Header_1
c.Offset(1, 0) = Header_2
c.Offset(1, 1) = Header_3
End If
Next c