View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Bernie Deitrick Bernie Deitrick is offline
external usenet poster
 
Posts: 5,441
Default Column-replying macro

N!,

Sub RowInsertMacroForNXau()
Dim myRow As Long
Dim Delta As Long
Dim i As Integer

Delta = 0
For myRow = 1 To Range("C65536").End(xlUp).Row
If IsNumeric(Cells(myRow, 3).Value) Then
For i = 2 To Cells(myRow + Delta, 3).Value
Rows(myRow + 1 + Delta).Insert
Cells(myRow + 1 + Delta, 1).Value = Cells(myRow + Delta, 1).Value
Cells(myRow + 1 + Delta, 2).Value = Cells(myRow + Delta, 2).Value
Next i
Delta = Delta + Cells(myRow + Delta, 3).Value - 1
End If
Next myRow
End Sub

HTH,
Bernie
MS Excel MVP

"N! Xau" wrote in message
...
Hi all,

I need help with a macro. The macro has to read number N into cell C

of
current row, insert N-1 rows under that, and copy values in columns

A and B.
For instance:

Befo

A B C
dataA2 dataB2 3
dataA3 dataB3 1
dataA4 dataB4 5
... ... ..

After:

A B C
dataA2 dataB2 3
dataA2 dataB2
dataA2 dataB2
dataA3 dataB3 1
dataA4 dataB4 5
dataA4 dataB4
dataA4 dataB4
dataA4 dataB4
dataA4 dataB4
... ... ..


Thanks a lot for help
N! Xau