Good morning,
So I am new to using arrays. But here is what I am trying to do.
I have a table (listobject) with two columns.
Basically these made up values is what the table looks like, but with something like 100+ rows
Server Library
200.123.123.23 ABC
201.124.243.24 DEF
231.123.123.54 GHI
What I want to do is to put that in an array and loop through each row. So the result would be that a "Server" and "Library" variable in my code becomes the values in the next row in the array with each loop.
So far I have figured out how to populate the array with the table using this.
Liblist = Worksheets("Library").ListObjects("Library").DataBodyRange.Value
And for testing I can cycle through the array values. in a Msgbox.
The below will cycle through the first column of values and then the second column of values.
Which makes me wonder if the array is actually 1 dimensional?
Sub arraytest()
Dim Liblist As Variant
Dim Library As Variant
Dim Server As Variant
Liblist = Worksheets("Library").ListObjects("Library").DataBodyRange.Value
For Each Server In Liblist
MsgBox Server
Next
End Sub
The part where I am lost is how to make sure my array is actually two dimensional and during each loop MsgBox the Server and Library column values for the row that the loop is on.
Or how to know I am actually looping through rows of the array and not just each element.
Or how to reference each column value for the row the loop is on, which calling out exact coordinates
If I can get that far then I will know that I can use the Server and Library in my code and know they are changing with each loop.
Anyhow, I appreciate your time and thanks in advance for helping me understand how to make this work.
So I am new to using arrays. But here is what I am trying to do.
I have a table (listobject) with two columns.
Basically these made up values is what the table looks like, but with something like 100+ rows
Server Library
200.123.123.23 ABC
201.124.243.24 DEF
231.123.123.54 GHI
What I want to do is to put that in an array and loop through each row. So the result would be that a "Server" and "Library" variable in my code becomes the values in the next row in the array with each loop.
So far I have figured out how to populate the array with the table using this.
Liblist = Worksheets("Library").ListObjects("Library").DataBodyRange.Value
And for testing I can cycle through the array values. in a Msgbox.
The below will cycle through the first column of values and then the second column of values.
Which makes me wonder if the array is actually 1 dimensional?
Sub arraytest()
Dim Liblist As Variant
Dim Library As Variant
Dim Server As Variant
Liblist = Worksheets("Library").ListObjects("Library").DataBodyRange.Value
For Each Server In Liblist
MsgBox Server
Next
End Sub
The part where I am lost is how to make sure my array is actually two dimensional and during each loop MsgBox the Server and Library column values for the row that the loop is on.
Or how to know I am actually looping through rows of the array and not just each element.
Or how to reference each column value for the row the loop is on, which calling out exact coordinates
If I can get that far then I will know that I can use the Server and Library in my code and know they are changing with each loop.
Anyhow, I appreciate your time and thanks in advance for helping me understand how to make this work.