Results 1 to 35 of 35

VBA For loop

Threaded View

  1. #1
    Registered User
    Join Date
    07-14-2014
    Location
    Germany
    MS-Off Ver
    2007
    Posts
    26

    VBA For loop

    I need a little help getting in the right direction and I should be fine from there.

    So the background here is i have a huge 10K line data file I need to search through and find up to three unique results given two conditions. the first condition has a possible of 93 outcomes and the second condition has a possible of 5 outcomes; for a total of about 10k random entries. I want to grow this function to fill lots of data but I keep getting random issues. consistently "error 1004".

    This 10k file is updated constantly and i need to create reports for every year in the future so you're help here is really appreciated.

    
    Private Sub CommandButton3_Click()
        Dim LastRow As String
        Dim z As Integer
        Dim CellOne As String
        Dim CellTwo As String
        Dim CellThree As String
        
        'get the row count for the loop
        Sheets("2015 DATA").Select
        LastRow = Cells(Rows.Count, "A").End(xlUp).Row
    
        'now we loop, match all countries and classes and output the factories
             CellOne = None
             CellTwo = None
             CellThree = None
        
            Sheets("2015 DATA").Select
            Range("A1").Select
            
        For z = 1 To LastRow
        If Worksheets("2015 DATA").Cells(z, 9).Value = "CO" And Worksheets("2015 DATA").Cells(z, 27).Value = "class 12" Then
        
        If CellOne = None Then CellOne = Worksheets("2015 DATA").Cells(z, 7).Value
        If CellTwo = None Then CellOne = Worksheets("2015 DATA").Cells(z, 7).Value
        If CellThree = None Then CellOne = Worksheets("2015 DATA").Cells(z, 7).Value
        
        End If
    
        Next z
        
          MsgBox (CellOne & CellTwo & CellThree)
    End Sub
    Last edited by iamGreenhorn; 07-17-2014 at 09:41 AM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. HOW TO: Pause loop, fix error on a popup UserForm, continue loop
    By AndyMachin in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 06-19-2014, 04:37 PM
  2. [SOLVED] Copy dynamically changing column and Paste using VBA Loop (Loop within Loop)
    By nixon72 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-12-2013, 12:46 PM
  3. Why did an inner loop variable start overwriting the outer loop range suddenly?
    By 111StepsAhead in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-16-2012, 03:24 PM
  4. Macro Loop Broken. Detects Max but doesn't continue loop
    By herchenbach in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-21-2011, 12:17 PM
  5. Replies: 0
    Last Post: 07-20-2010, 11:42 AM

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