Results 1 to 3 of 3

Thread: [RESOLVED] Loop problem

Threaded View

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2005
    Posts
    393

    Resolved [RESOLVED] Loop problem

    Hello experts
    I need to the following algorithm:

    List of parts some prefixed ND/SD and others not prefixed ND/SD. For only 1 of each part (the same part can occur muultiple times sheet 1 "start with") i need to create 4 levels for parts not prefixed ND/SD and 2 levels for parts prefixed ND/SD for a standard partern depending on the starting.

    Please see the start with and what I need to create (end with) programmatically. Please see the code so far for the small program and attached spreadsheet - please view the start with (data we need to manipulate) and end with sheet (what it needs to look like). I don't have anyything on levels within the code but this needs to be included.



    VB Code:
    1. Sub fullstructure()
    2. Dim i As Long
    3. Dim usedrange As Long
    4. Dim rngdata As Range
    5. Dim counter As Long
    6.  
    7. With Worksheets(1)
    8. usedrange = .usedrange.Rows.Count
    9. Set rngdata = .Range(.Cells(1, 1), .Cells(usedrange, 1))
    10. End With
    11.  
    12. counter = 1
    13. With rngdata
    14. For i = 1 To .Rows.Count
    15. If .Cells(i, 1) <> Cells(i + 1, 1) Then
    16. 'If Left(i, 2) <> "ND" Or _
    17. 'Left(i, 2) <> "SD" Then
    18. Worksheets(2).Cells(counter, 1) = "CN-" & Cells(i, 1)
    19. 'Worksheets(2).Cells(counter + 1, 1) = "KIT-CN-" & Cells(i, 1)
    20. 'Worksheets(2).Cells(counter + 2, 1) = "IK-" & Cells(i, 1)
    21. 'Worksheets(2).Cells(counter + 3, 1) = "EBS-" & Cells(i, 1)
    22. counter = counter + 1
    23. 'Else
    24. 'Worksheets(2).Cells(counter, 1) = "CN-" & Cells(i, 1)
    25. 'Worksheets(2).Cells(counter + 1, 1) = Cells(i, 1)
    26. 'counter = counter + 1
    27. 'End If
    28. End If
    29. Next i
    30. End With
    31.  
    32. finish:
    33. End Sub

    Borris.
    Attached Files Attached Files

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width