ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   plz help...simple stuff (https://www.excelbanter.com/excel-discussion-misc-queries/103069-plz-help-simple-stuff.html)

vincent135

plz help...simple stuff
 

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


--
vincent135
------------------------------------------------------------------------
vincent135's Profile: http://www.excelforum.com/member.php...o&userid=35373
View this thread: http://www.excelforum.com/showthread...hreadid=568146


Excelenator

plz help...simple stuff
 

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 Sub
--------------------


--
Excelenator


------------------------------------------------------------------------
Excelenator's Profile: http://www.excelforum.com/member.php...o&userid=36768
View this thread: http://www.excelforum.com/showthread...hreadid=568146



All times are GMT +1. The time now is 10:09 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com