Yes, your original data does not represent that each string of A-B-C-D are actually related. Much better to post real sample data like you did.
Here you, this will keep the related materials together, with data in columns A:B, run this:
Option Explicit
Sub Reformat()
Dim MyRNG As Range, cell As Range, NR As Long
Dim str1 As String, str2 As String, str3 As String, str4 As String
Set MyRNG = ActiveSheet.Range("A:A").SpecialCells(xlConstants)
Range("D1:G1").Value = [{"variableParameter","formula","meanValue","comment"}]
NR = 2
For Each cell In MyRNG
Select Case cell.Value
Case "variableParameter"
If str1 <> "" Then
Range("D" & NR) = str1
Range("E" & NR) = str2
Range("F" & NR) = str3
Range("G" & NR) = str4
NR = NR + 1
End If
str1 = cell.Offset(, 1).Value
str2 = ""
str3 = ""
str4 = ""
Case "formula"
str2 = cell.Offset(, 1).Value
Case "meanValue"
str3 = cell.Offset(, 1).Value
Case "comment"
str4 = cell.Offset(, 1).Value
End Select
Next cell
Range("D" & NR) = str1
Range("E" & NR) = str2
Range("F" & NR) = str3
Range("G" & NR) = str4
Range("D:G").Columns.AutoFit
End Sub
Bookmarks