On my sheet I have a loop running to cycle through all necessary rows in a column, and then to loop back to the first row of the next column. The loop works fine when I run the code below with just the .Select line (i.e. I can see the cells being selected and looped correctly). Where I'm having trouble is getting a ROUNDDOWN calculation result populated in each cell of the loop. The calculation needs to be done using cells in column C of the active row and row 3 of the active column.
Here's the snippet of VBA for the loop... (sorry i don't know how to post the code here)
For c = 5 To LastCol
For r = 7 To LastRow
Cells(r, c).Select
Selection.Value = Application.WorksheetFunction.RoundDown("C" & r * c & "3", 0)
Next r
Next c
So in essence I want E7 to have the result of ROUNDDOWN($C7*E$3,0) populated, with the same calc happening in E8, E9, etc and then eventually looping back to F7, F8, F9 etc. I just don't know how to tell the VBA RoundDown function to calculate on the looping row and column numbers. HELP!
Thanks
Mike
Allocation Sheet v2.xls | ||||||||
---|---|---|---|---|---|---|---|---|
A | B | C | D | E | F | |||
1 | OriginalOrderQuantity | 15,910 | ClientName | Smith | Jones | |||
2 | ExecutedOrderQuantity | 0 | OrderQty | 4,312 | 2,661 | |||
3 | %ofTotalOrder | 27.1025% | 16.7253% | |||||
4 | SharestobeAllocated | 0 | 0 | |||||
5 | ||||||||
6 | Quantity | Price | ||||||
7 | 300 | 25.89 | 81 | 50 | ||||
8 | 300 | 25.895 | 81 | 50 | ||||
9 | 500 | 25.9 | 135 | 83 | ||||
10 | 800 | 25.91 | 216 | 133 | ||||
11 | 100 | 25.92 | 27 | 16 | ||||
12 | 200 | 25.93 | 54 | 33 | ||||
13 | 500 | 25.95 | 135 | 83 | ||||
14 | 400 | 25.97 | 108 | 66 | ||||
Sheet1 |
Here's the snippet of VBA for the loop... (sorry i don't know how to post the code here)
For c = 5 To LastCol
For r = 7 To LastRow
Cells(r, c).Select
Selection.Value = Application.WorksheetFunction.RoundDown("C" & r * c & "3", 0)
Next r
Next c
So in essence I want E7 to have the result of ROUNDDOWN($C7*E$3,0) populated, with the same calc happening in E8, E9, etc and then eventually looping back to F7, F8, F9 etc. I just don't know how to tell the VBA RoundDown function to calculate on the looping row and column numbers. HELP!
Thanks
Mike