• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

VBA to repeat numeric value based on value from other cell

dgk

Member
Hi
I would greatly appreciate some help with this.
I need a vba excel macro to automate filling in qty per box taken from column B , to the amount of column’s to the right based on column C , and to repeat this for all (rows) items on the list where column A is not blank
See sample file attached 2 sheets the 2nd sheet is how it should come out
Thanks a lot
 

Attachments

  • SHIPMENT WITH BX INFO.xlsx
    12.7 KB · Views: 3
or

VBA Solution.


Code:
Option Explicit

Sub Filled_The_Qty()
Dim i As Long, k As Long
Dim increment As Long
increment = 5

Dim lrow As Long
lrow = Range("A" & Rows.Count).End(xlUp).Row

Range("E2", Range("E1").SpecialCells(xlLastCell)).Select
Selection.Clear

'Change According to
For i = 2 To lrow

    For k = 1 To Cells(i, 3).Value
        Cells(i, increment).Value = Cells(i, 2).Value
        increment = increment + 1
    
    Next k

increment = 5

Next i
End Sub
 
Back
Top