Hi, DeepthiBas9,
maybe like this (please use a copy of the worksheet for testing and adapt the ranges as needed):
Sub EF1005692()
Dim var As Variant
Dim varTemp As Variant
Dim lngCounter As Long
Dim lngInCount As Long
With ActiveSheet
ReDim var(2 To .Range("A" & Rows.Count).End(xlUp).Row, 1 To 2)
var = .Range("A2:B" & .Range("A" & Rows.Count).End(xlUp).Row).Value
.Range("A2:B" & .Range("A" & Rows.Count).End(xlUp).Row).ClearContents
For lngCounter = LBound(var, 1) To UBound(var, 1)
With .Range("A" & Rows.Count).End(xlUp).Offset(1, 0)
.Value = var(lngCounter, 1)
.Offset(0, 1).Value = var(lngCounter, 2)
End With
For lngInCount = 1 To var(lngCounter, 1) - 1
With .Range("A" & Rows.Count).End(xlUp).Offset(1, 0)
.Value = var(lngCounter, 1)
.Offset(0, 1).Value = 0
End With
Next lngInCount
Next lngCounter
End With
End Sub
How to install your new code
- Copy the Excel VBA code
- Select the workbook in which you want to store the Excel VBA code
- Press Alt+F11 to open the Visual Basic Editor
- Choose Insert > Module
- Edit > Paste the macro into the module that appeared
- Close the VBEditor
- Save your workbook (Excel 2007+ select a macro-enabled file format, like *.xlsm)
To run the Excel VBA code:- Press Alt-F8 to open the macro list
- Select a macro in the list
- Click the Run button
Ciao,
Holger
Bookmarks