Results 1 to 20 of 23

Thread: Helping a student automate a couple of sheets

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #8
    VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,709
    Location
    If I comprehend your issue, you want a set of numbers applied to Sheet "Input," then run ertert, then apply the next set of numbers, the run ertert. . .Rinse and repeat.

    In that case, Module 1 code should be
    Option Explicit 
     
    Sub ertert() 
        Dim x, i&, j& 
        With Sheets("Counter Totals") 
            x = .Range("A2:CM" & .Cells(Rows.Count, 1).End(xlUp).Row).Value 
        End With 
        For i = 1 To UBound(x) 'The LBound of x is 0 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
            If (x(i, 1)) = "Game" Then j = j + 1 
            If (IsNumeric(x(i, 1))) * (Len(x(i, 1))) Then 
                With Sheets("Game" & x(i, 1)).Columns(1).SpecialCells(2) 
                    .Areas(j)(.Areas(j).Count + 1, 1).Resize(, 91).Value = Application.Index(x, i, 0) 
                End With 
            End If 
        Next i 
        NumbersGrabber 'get more numbers '<<<<<<<<<<<<<<<<<<<<<<
    
    End Sub 
     
    Sub ClearGames() 
    'as is
    End Sub 
    
    Sub NumbersGrabber() 
        Dim InputSht As Worksheet 
        Dim DrnNumSht As Worksheet 
         
        Static NextRowToUse As Long 'maintains State between calls as long as Workbook is open. With caveats.
         
        Set InputSht = Sheets("Input") 
        Set DrnNumSht = Sheets("Drawn Numbers") 
         
        If NextRowToUse = 0 Then NextRowToUse = 2500 
        If NextRowToUse = 1 Then Exit Sub 
         
        DrnNumSht.Cells(NextRowToUse, "I").Resize(, 7).Copy 'Resize(0 Rows, 7 Columns)
        InputSht.Range("I49").Resize(, 7).Insert shift:=xlShiftDown 
        NextRowToUse = NextRowToUse - 1 
         
        ertert 'Run the etert Procedure
        '<><><><><><><><><><><>
         
    End Sub
    However, Sub ertert runs on every contiguous block of cells on the entire sheet every time it runs, so it doesn't make sense to "Rinse and repeat."

    Further, ertert pulls values from Sheet "CounterTotals" and puts them in a Game sheet. NumbersGrabber puts values in Sheet "Input," but ertert doesn't use them.
    Last edited by SamT; 09-28-2016 at 07:39 AM.
    Please take the time to read the Forum FAQ

Posting Permissions

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