Use value in a cell to iterate and fill target Columns

Logan_Noob

New Member
Joined
Jul 28, 2012
Messages
2
Hi Every1,

I have got myself a little trouble..

The functionality of the code is quite simple but i being a beginner am not able to do it .

I have 3 columns
  1. Number of iterations
  2. Data to be repeated
  3. Target block

I am trying to fetch the value of each cell in the 1 st column as the counter for the loop and then use it to repeatedly print the data of the 2 nd column into the target that is the 3 rd column.

NumberofIterationDataToBeRepeated(String)Target BlockResult
1L01L01
0L020
2L02L02
4L01L02
L01
L01
L01
L01

<tbody>
</tbody>

Your help is highly appreciated .Thanx in advance

Regards
Logan_Noob
 
Last edited:

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
Try

Code:
Sub block()
Dim LR As Long, i As Long
LR = Range("A" & Rows.Count).End(xlUp).Row
For i = 2 To LR
    If Range("A" & i).Value > 0 Then
        Range("C" & Rows.Count).End(xlUp).Offset(1).Resize(Range("A" & i).Value).Value = Range("B" & i).Value
    Else
        Range("C" & Rows.Count).End(xlUp).Offset(1).Value = 0
    End If
Next i
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,584
Messages
6,125,666
Members
449,248
Latest member
wayneho98

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top