A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data.
If I understand what you are attempting to do, then I have a much simpler macro for you to use. Let's see if I understand what you have and what you want to do with it. You have a count value in Column A and Columns B and C contain some information that is to be repeated for each data item in the rest of the row. Columns D through W have data in them (by the way, you posted Columns N through W in your description above, but I assumed that was wrong), possibly with blanks or runs of blanks located between them. You want to move all the non-blank data into Column D, one piece of data per row. To do that, you want to insert the necessary amount of rows to accommodate the data, then you want to fill the blanks in Columns A through C with the data in the non-blank cells above them. Does that sound right? Assuming your answer was yes, I think this much shorter macro will do that...
Sub TransposeData()
Dim X As Long, LastRow As Long, LastColumn As Long, DataCount As Long, NonTransposableColumnCount As Long, Area As Range
Const StartRow As Long = 2
Const FirstTransposableColumn As String = "D"
NonTransposableColumnCount = Columns(FirstTransposableColumn).Column - 1
LastRow = Cells(Rows.Count, "A").End(xlUp).Row
For X = LastRow To StartRow Step -1
Cells(X, FirstTransposableColumn).Resize(1, 20).SpecialCells(xlCellTypeBlanks).Delete xlShiftToLeft
LastColumn = Cells(X, Columns.Count).End(xlToLeft).Column
DataCount = LastColumn - NonTransposableColumnCount
Rows(X + 1).Resize(DataCount - 1).Insert
Cells(X, FirstTransposableColumn).Resize(DataCount) = WorksheetFunction.Transpose(Cells(X, FirstTransposableColumn).Resize(1, 20))
Cells(X + 1, "A").Resize(DataCount - 1, NonTransposableColumnCount).Value = Cells(X, "A").Resize(1, NonTransposableColumnCount).Value
Cells(X, FirstTransposableColumn).Offset(0, 1).Resize(1, DataCount - 1).Clear
Next
End Sub
Note that above code does not use the count value in Column A at all. So, if it would no screw up the rest of your worksheets (because of referencing into the sheet this macro is run against), you could remove Column A completely (that is, select the column and Edit/Delete it) and use this code instead (it is the above code modified to repeat what would be in Columns A and B after the count value column has been deleted...
Sub TransposeData()
Dim X As Long, LastRow As Long, LastColumn As Long, DataCount As Long, NonTransposableColumnCount As Long, Area As Range
Const StartRow As Long = 2
Const FirstTransposableColumn As String = "C"
NonTransposableColumnCount = Columns(FirstTransposableColumn).Column - 1
LastRow = Cells(Rows.Count, "A").End(xlUp).Row
For X = LastRow To StartRow Step -1
Cells(X, FirstTransposableColumn).Resize(1, 20).SpecialCells(xlCellTypeBlanks).Delete xlShiftToLeft
LastColumn = Cells(X, Columns.Count).End(xlToLeft).Column
DataCount = LastColumn - NonTransposableColumnCount
Rows(X + 1).Resize(DataCount - 1).Insert
Cells(X, FirstTransposableColumn).Resize(DataCount) = WorksheetFunction.Transpose(Cells(X, FirstTransposableColumn).Resize(1, 20))
Cells(X + 1, "A").Resize(DataCount - 1, NonTransposableColumnCount).Value = Cells(X, "A").Resize(1, NonTransposableColumnCount).Value
Cells(X, FirstTransposableColumn).Offset(0, 1).Resize(1, DataCount - 1).Clear
Next
End Sub
NOTE: Please mark the message or messages (yes, you can mark more than one) that answer your question as the "Answer" so that others will know your question has been resolved.