Hi to all,
i have data like this
text rows to repeat elements in row
MB1 2 16
MB2 3 3
MB3 1 16
MB4 4 15
MB5 5 8
i want to paste text for MB1 in column B like from MB1-1 to MB1-16 and MB1 2-1 to MB 2-16 because MB1 has 2 rows and 16 elements to repeat, for MB2 in cloumn B like MB2 1-1 to MB2 1-3 and MB2 2-1 to MB2 2-3 and MB2 3-1 to MB2 3-3 because MB has 3 rows and 3 elements to repeat like this i want to continue upto MB5
I am expecting like this
A B
MB1 MB1 1-1
.
.
.
MB1 1-16
MB1 2-1
.
.
.
MB1 2-16
MB2 1-1
.
MB2 1-3
MB2 2-1
.
MB2 2-3
and i would like to continue this for the rest of text in column A .Here i tried with commond button simple and now i am in position to paste text in a given range but not the way i am expecting.
here is my code
Private Sub CommandButton1_Click()
Dim Lastrow As Long
Dim Cell As Range
Dim i As Long
Dim r As Long
Lastrow = Range("A" & Rows.Count).End(xlUp).Row
For Each Cell In Range("A1:A" & Lastrow)
For i = 1 To 20
r = r + 1
Range("B" & r).Value = Cell.Value & " 1-" & Format(i, "00")
Next i
For i = 1 To 20
r = r + 1
Range("B" & r).Value = Cell.Value & " 2-" & Format(i, "00")
Next i
Next Cell
End Sub
I need to sovle this problem or needs editing to this VBA code to reach my objective. any help would be appreciated
Thanking you
Bookmarks