VBA for next loops

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.

Num 1Num 2Num 3Num 4Num 5PowerballStatus
5135482252
134739495719
2959506371
586635571718
475637662215
2963121411
50585948318
573140445515
26645023679
40263642326
62322734394
36455767503
302528655611
73644677
164558322926Winner
6316038408
44346936159
2556634349
35673696115
5494283222
25642250319

<tbody>
</tbody>
 
Last edited:

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
I assume the "Solution" is the template that the assignment wants you to follow?

If so, your code should have determined the value of LRow - it looks like 16 to me, assuming your headers are in row 1? Have you got this far?

You are then being asked to write a loop to put the six values in A16:F16 (i.e row 16 and columns 1 to 6) into your lottery() array.

What code have you tried for this?
 
Upvote 0

Forum statistics

Threads
1,215,479
Messages
6,125,043
Members
449,206
Latest member
Healthydogs

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top