+ Reply to Thread
Results 1 to 8 of 8

Help with Loops

  1. #1
    Registered User
    Join Date
    09-11-2006
    Location
    Market Haborough
    Posts
    3

    Talking Help with Loops

    I have a workbook, with 13 sheets, 1st one named Summary, and the rest ProdLine1 to 12 representing production lines. The ProdLines contains various information on orders going through production. I need to find a way in VB to loop though all the ProdLines and check if an Order in Column A contains the word "InProd". If it has, then copy the entire row to the Summary sheet., and then loop through to the next order with “InProd” and copy that row to the Summary sheet, an so on through all the ProdLines.

    Due to my inexperience of VB, I have spent a great deal of time trying to find a solution to this problem, but I hope someone out there will come to my rescue. Thanking you all in advance.

  2. #2
    Forum Contributor stevebriz's Avatar
    Join Date
    09-07-2006
    Location
    Santiago Chile
    Posts
    389
    Post what code you have and then we can look at it
    VBA - The Power Behind the Grid

    Posting a sample of your workbook makes it easier to look at the Issue.

  3. #3
    Registered User
    Join Date
    09-11-2006
    Location
    Market Haborough
    Posts
    3
    Hi stevebriz
    This is what I have so far.

    Sub InProd()
    Dim i As Integer
    i = 2
    Do Until IsEmpty(Cells(i, 1))
    If Cells(i, 1).Value = "InProd" Then
    Selection.Copy
    Worksheets("Summary").Select
    Worksheets("Summary").Range("A1").Select
    Selection.End(xlDown).Select
    ActiveCell.Offset(1, 0).Range("A1").Select
    ActiveSheet.Paste

    End If

    i = i + 2
    Loop

    End Sub

    Thanks
    manoj

  4. #4
    Forum Contributor stevebriz's Avatar
    Join Date
    09-07-2006
    Location
    Santiago Chile
    Posts
    389
    try this

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    09-11-2006
    Location
    Market Haborough
    Posts
    3
    Hi stevebriz,
    It works beautiful. A great big thank You.

  6. #6
    Registered User
    Join Date
    09-03-2006
    Posts
    8
    Quote Originally Posted by stevebriz
    try this

    Please Login or Register  to view this content.

    Hello Steve,

    I came across your code, and I have found very useful, however how would I make a reference to sheets 1 to 12 if they are in a separate workbook, say on my c drive called " Data"?

    Thanking you for your time
    Regards
    Odggi

  7. #7
    Forum Contributor
    Join Date
    07-12-2005
    Posts
    143
    Hi all,

    also found this script really handy. But how would you adapt it for two conditions - e.g a specific date or range of dates in column b.


    thanks for all the help as usual...

  8. #8
    Forum Contributor
    Join Date
    11-11-2005
    Posts
    267
    Oddgi,

    ... how would I make a reference to sheets 1 to 12 if they are in a separate workbook, say on my c drive called " Data"?
    Tweak:

    For sht = 1 To 12 ' sheets ( 1 to 12) production sheets
    SHTNM = "ProdLine" & sht
    Sheets(SHTNM).Select
    With Sheets(SHTNM).Range("A1", Range("A65536").End(xlUp).Address)

    To:

    For sht = 1 To 12 ' sheets ( 1 to 12) production sheets
    SHTNM = "ProdLine" & sht
    Sheets(SHTNM).Select
    With Workbooks("Data").Sheets(SHTNM).Range("A1", Range("A65536").End(xlUp).Address)

    assuming your other Workbook is named "Data" and everything else (sheet names etc) remain the same; the adaption will also mean that you can run the code from outside of Workbooks("Data")--generally, provided it is open.

    Steve's code acts on the ACTIVE WORKBOOK. Hence, if you stick his original code, lock, stock and barrel, in the general module of your WorkBook called "Data", there should be no problems running it. I am a bit taken aback why you came up with the request.
    HTH
    Myles

    ...constantly looking for the smoother pebble while the whole ocean of truth lies before me.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1