Loop on all the rows of an array
Code:
Sub loop_on_rows_Array()
Dim ws_sheet As Worksheet
Dim lastrow As Long
Dim lastcolumn As Long
Dim array_data() As Variant
'identify worksheet
Set ws_sheet = Worksheets(2)
'find table's limits
lastrow = ws_sheet.Cells(Rows.Count, 1).End(xlUp).Row
lastcolumn = ws_sheet.Cells(1, Columns.Count).End(xlToLeft).Column
'save table in array
array_data = ws_sheet.Range(ws_sheet.Cells(1, 1), ws_sheet.Cells(lastrow, lastcolumn))
'loop on rows
For i = LBound(array_data) + 1 To UBound(array_data)
'your code here
'example: sum of the column's B values
sum_B = sum_B + array_data(i, 2)
Next
MsgBox ("Sum is: " & sum_B)
End Sub
-------------------------------
NEED HELP?
-------------------------------
Leave a comment with your questions, issues or projetcs and I will try to answer with a video.
-------------------------------
THANK YOU
-------------------------------
For watching my videos,
Your shares
And your comments!