• 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.

How to get output under gap critera?

Ashish Balki

New Member
I have attached a workbook containing 2 sheets. First sheet comprises of the data for the sheet. @nd sheet names output has to be in the format given. I have hardcoded the number to give an idea. How can I make this process automatic?
 

Attachments

  • Chandoo_Ashish Balki.xlsx
    16.4 KB · Views: 7
Try this macro.....

Code:
Sub test()
Dim ws_in, ws_out As Worksheet
Set ws_in = Worksheets("In-Put")
Set ws_out = Worksheets("Output")
c_in = ws_in.Cells(ws_in.Cells.Rows.Count, 1).End(xlUp).Row
c_out = ws_out.Cells(ws_out.Cells.Rows.Count, 1).End(xlUp).Row

For i = 3 To c_out
If ws_out.Range("c" & i) <> "" Then
start_wk = Application.WorksheetFunction.VLookup(ws_out.Range("c" & i), ws_in.Range("b:k"), 7, 0)
Range_WK = Application.WorksheetFunction.VLookup(ws_out.Range("c" & i), ws_in.Range("b:k"), 8, 0)
Gap_wk = Application.WorksheetFunction.VLookup(ws_out.Range("c" & i), ws_in.Range("b:k"), 9, 0)
end_wk = Application.WorksheetFunction.VLookup(ws_out.Range("c" & i), ws_in.Range("b:k"), 10, 0)
Min = Application.WorksheetFunction.VLookup(ws_out.Range("c" & i), ws_in.Range("b:k"), 2, 0)
Val1 = Application.WorksheetFunction.VLookup(ws_out.Range("c" & i), ws_in.Range("b:k"), 6, 0)

If Gap_wk = 0 Then end_wk = end_wk Else end_wk = ((Range_WK * Gap_wk) - 1) + end_wk
For j = (start_wk + 3) To (end_wk + 3) Step Gap_wk + 1
ws_out.Cells(i, j).Value = (Val1 * Min) / 100
Next j
End If

Next

End Sub 
[CODE/]
 
check this file....press run button which was placed on output sheet....
 

Attachments

  • Chandoo_Ashish Balki.xlsm
    28.5 KB · Views: 4
Back
Top