View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Norman Jones Norman Jones is offline
external usenet poster
 
Posts: 5,302
Default generate multi row event from single entry

Hi Stratis,

Try something like:

'=============
Public Sub Tester001()
Dim rng As Range
Dim i As Long, j As Long

Set rng = Selection '<<==== CHANGE

If rng.Columns.Count 1 Then
Set rng = rng.Resize(, 1)
End If

For i = rng.Rows.Count To 1 Step -1
With rng(i)
If Not IsNumeric(.Offset(0, 1).Value) _
Or .Offset(0, 1).Value < 1 Then
.Resize(1, 2).Delete shift:=xlUp
Else
j = .Offset(0, 1).Value
.Offset(1).Resize(j - 1, 2).Insert shift:=xlDown
.Resize(1, 2).Copy Destination:=.Resize(j)
End If
End With
Next i

End Sub
'<<=============


---
Regards,
Norman


"stratis" wrote in message
...
If I have an spreadsheet of the type
position 1 2
position 2 3
etc
is there a macro I can generate
position 1
position 1
position2
position2
position2
etc