Chris Macro
Well-known Member
- Joined
- Nov 2, 2011
- Messages
- 1,345
- Office Version
- 365
- Platform
- Windows
I can't get the syntax for my For Each statement, any suggestions on how to code the first line? I am wanting to loop through each row in my table.
<font face=Calibri><SPAN style="color:#00007F">For</SPAN> <SPAN style="color:#00007F">Each</SPAN> Rw <SPAN style="color:#00007F">In</SPAN> ThisWorkbook.Worksheets(Data.Name).ListObjects("myStockPurchases").DataBodyRange.Rows<br> <SPAN style="color:#00007F">If</SPAN> Rw.Columns("Stocks").Value = SectorType And Rw.Columns("Buy/Sell").Value = "Bought" <SPAN style="color:#00007F">Then</SPAN><br> QuantityArray(m) = Rw.Columns("Quantity").Value<br> TotalArray(m) = Rw.Columns("Price").Value<br> m = m + 1<br> <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">If</SPAN><br><SPAN style="color:#00007F">Next</SPAN> Rw<br></FONT>
<font face=Calibri><SPAN style="color:#00007F">For</SPAN> <SPAN style="color:#00007F">Each</SPAN> Rw <SPAN style="color:#00007F">In</SPAN> ThisWorkbook.Worksheets(Data.Name).ListObjects("myStockPurchases").DataBodyRange.Rows<br> <SPAN style="color:#00007F">If</SPAN> Rw.Columns("Stocks").Value = SectorType And Rw.Columns("Buy/Sell").Value = "Bought" <SPAN style="color:#00007F">Then</SPAN><br> QuantityArray(m) = Rw.Columns("Quantity").Value<br> TotalArray(m) = Rw.Columns("Price").Value<br> m = m + 1<br> <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">If</SPAN><br><SPAN style="color:#00007F">Next</SPAN> Rw<br></FONT>