Column-replying macro
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 |
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 |
Column-replying macro
"Bernie Deitrick" <deitbe @ consumer dot org wrote in message Sub RowInsertMacroForNXau() [cut] HTH, Bernie MS Excel MVP Thank you very much, it works great! N! Xau |
All times are GMT +1. The time now is 04:19 AM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com