plz help...simple stuff

  • Thread starter Thread starter vincent135
  • Start date Start date
V

vincent135

i got

1
1
2
2
3
3
4
4

and i want them to become

1
2
3
1
2
3
4
5
6
4
5
6
7
8
9
7
8
9
10
11
12
10
11
12

ie
1 expands to 1 2 3
2 expands to 4 5 6
3 expands to 7 8 9
4 expands to 10 11 12

pls help
 
Here you go.


Code
-------------------
Sub Convert()
Dim i As Integer
Dim r As Long
Dim s As Range


Set s = Application.InputBox("Select range to be converted", "Range Selection", , , , , , 8)
s.Select
ActiveCell.Select

For r = 1 To s.Rows.Count
Range(Selection.Offset(1, 0), Selection.Offset(2, 0)).Insert Shift:=xlDown
Select Case ActiveCell.Value
Case 1
For i = 0 To 2
Selection.Offset(i, 0).Value = ActiveCell.Value + i
Next i
Selection.Offset(3, 0).Select
Case 2
For i = 0 To 2
Selection.Offset(i, 0).Value = 4 + i
Next i
Selection.Offset(3, 0).Select
Case 3
For i = 0 To 2
Selection.Offset(i, 0).Value = 7 + i
Next i
Selection.Offset(3, 0).Select
Case 4
For i = 0 To 2
Selection.Offset(i, 0).Value = 10 + i
Next i
Selection.Offset(3, 0).Select
Case Else
Exit Sub
End Select
Next r

End Su
-------------------
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top