How would you go about printing information on a second line while still in the same "a" in the for loop?
Referencing the below code, away_ml should be printed in (4,5), but home_ml should be in (5,5). Currently, the code I have prints the first line correctly, but then does not print the "a+1" like I am intending.
I don't think I can use the Step method in the intial for loop line (For a=4 to g step 2) as I would miss rows that I need to pull information from.
Uploaded is an example file with it correctly copied on the right hand side of the sheet. Below is my current code.
![]()
Sub Simulate() a = 4 g = Sheet3.Cells(Rows.Count, "B").End(xlUp).Row Sheet3.Range("K4:BF101").ClearContents Dim away_team As String Dim home_team As String Dim away_ML As Long Dim home_ML As Long Dim away_line As String Dim home_line As String Dim loca As String For a = 4 To g away_team = Sheet3.Cells(a, 7).Value home_team = Sheet3.Cells(a, 8).Value away_ML = Sheet3.Cells(a, 4).Value home_ML = Sheet3.Cells(a, 5).Value home_line = Sheet3.Cells(a, 3).Value away_line = home_line * -1 loca = Sheet3.Cells(a, 6).Value If loca = "H" Then Sheet3.Cells(a, 11).Value = Sheet3.Cells(a, 2).Value & "A" Sheet3.Cells(a + 1, 11).Value = Sheet3.Cells(a, 2).Value & "B" Sheet3.Cells(a, 12).Value = "A" Sheet3.Cells(a + 1, 12).Value = "H" Sheet3.Cells(a, 13).Value = away_line Sheet3.Cells(a + 1, 13).Value = home_line Sheet3.Cells(a, 14).Value = away_ML Sheet3.Cells(a + 1, 14).Value = home_ML Sheet3.Cells(a, 15).Value = away_team Sheet3.Cells(a + 1, 15).Value = home_team Sheet3.Cells(a, 16).Value = home_team Sheet3.Cells(a + 1, 16).Value = away_team ElseIf loca = "N" Then Sheet3.Cells(a, 11).Value = Sheet3.Cells(a, 2).Value + "A" Sheet3.Cells(a + 1, 11).Value = Sheet3.Cells(a, 2).Value + "B" Sheet3.Cells(a, 12).Value = "N" Sheet3.Cells(a + 1, 12).Value = "N" Sheet3.Cells(a, 13).Value = away_line Sheet3.Cells(a + 1, 13).Value = home_line Sheet3.Cells(a, 14).Value = away_ML Sheet3.Cells(a + 1, 14).Value = home_ML Sheet3.Cells(a, 15).Value = away_team Sheet3.Cells(a + 1, 15).Value = home_team Sheet3.Cells(a, 16).Value = home_team Sheet3.Cells(a + 1, 16).Value = away_team End If Next a End Sub











LinkBack URL
About LinkBacks
Register To Reply


Bookmarks