rinneii
New Member
- Joined
- Mar 20, 2019
- Messages
- 18
EDIT: I meant VBA !!! I tried doing VBA: but I ended up putting an L instead >_>
For one of my assignments I need to do as follows:
Obtain winning numbers through last row in column G: Type Winner in column G for any row you choose. Write a macro to capture the six winning numbers in that row in an array, and display in H3:H8 with a header “Winning Numbers” in H2.
Solution
DIM statements: lottery(1 to 6) as Integer; i as Integer, j As Integer, Lrow As Integer, wn_header As String
Delete column H to erase any numbers in column H
Use the last row technique to find the row with Winner in column G, and put it in variable Lrow
For-Next loop from column A to column F to capture winning numbers in lottery(1) to lottery(6). Designate ranges with Cells(row,column). Use Lrow for the row, and counter i for the column.
Put text “Winning Numbers” in variable wn_header
Put wn_header in cell H2
For-Next loop to enter lottery(1) to lotter(6) in cells H3:H8. Use counter starting at 3, and going to 8 (place in row position of Cells way of addressing ranges). Column position is 8.
I'm having issues with the for next loop. I'm not exactly sure how to do it :'|
Here's the data we start off with. I added "Winner" already.
[TABLE="width: 454"]
<tbody>[TR]
[TD]Num 1[/TD]
[TD]Num 2[/TD]
[TD]Num 3[/TD]
[TD]Num 4[/TD]
[TD]Num 5[/TD]
[TD]Powerball[/TD]
[TD]Status[/TD]
[/TR]
[TR]
[TD]51[/TD]
[TD]35[/TD]
[TD]48[/TD]
[TD]22[/TD]
[TD]5[/TD]
[TD]2[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]13[/TD]
[TD]47[/TD]
[TD]39[/TD]
[TD]49[/TD]
[TD]57[/TD]
[TD]19[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]29[/TD]
[TD]59[/TD]
[TD]50[/TD]
[TD]63[/TD]
[TD]7[/TD]
[TD]1[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]58[/TD]
[TD]66[/TD]
[TD]35[/TD]
[TD]57[/TD]
[TD]17[/TD]
[TD]18[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]47[/TD]
[TD]56[/TD]
[TD]37[/TD]
[TD]66[/TD]
[TD]22[/TD]
[TD]15[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[/TD]
[TD]9[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]25[/TD]
[TD]56[/TD]
[TD]63[/TD]
[TD]43[/TD]
[TD]4[/TD]
[TD]9[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]35[/TD]
[TD]67[/TD]
[TD]3[/TD]
[TD]69[/TD]
[TD]61[/TD]
[TD]15[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]5[/TD]
[TD]49[/TD]
[TD]4[/TD]
[TD]28[/TD]
[TD]32[/TD]
[TD]22[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]25[/TD]
[TD]64[/TD]
[TD]22[/TD]
[TD]50[/TD]
[TD]31[/TD]
[TD]9[/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
For one of my assignments I need to do as follows:
Obtain winning numbers through last row in column G: Type Winner in column G for any row you choose. Write a macro to capture the six winning numbers in that row in an array, and display in H3:H8 with a header “Winning Numbers” in H2.
Solution
DIM statements: lottery(1 to 6) as Integer; i as Integer, j As Integer, Lrow As Integer, wn_header As String
Delete column H to erase any numbers in column H
Use the last row technique to find the row with Winner in column G, and put it in variable Lrow
For-Next loop from column A to column F to capture winning numbers in lottery(1) to lottery(6). Designate ranges with Cells(row,column). Use Lrow for the row, and counter i for the column.
Put text “Winning Numbers” in variable wn_header
Put wn_header in cell H2
For-Next loop to enter lottery(1) to lotter(6) in cells H3:H8. Use counter starting at 3, and going to 8 (place in row position of Cells way of addressing ranges). Column position is 8.
I'm having issues with the for next loop. I'm not exactly sure how to do it :'|
Here's the data we start off with. I added "Winner" already.
[TABLE="width: 454"]
<tbody>[TR]
[TD]Num 1[/TD]
[TD]Num 2[/TD]
[TD]Num 3[/TD]
[TD]Num 4[/TD]
[TD]Num 5[/TD]
[TD]Powerball[/TD]
[TD]Status[/TD]
[/TR]
[TR]
[TD]51[/TD]
[TD]35[/TD]
[TD]48[/TD]
[TD]22[/TD]
[TD]5[/TD]
[TD]2[/TD]
[TD][/TD]
[/TR]
[TR]
[T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