Good Evening,
Can someone help me out with this one? I am trying to look for matching values from column A within column B, and if a match is found; then to bring the value of Column B + 1 column over to Column A + 1 column. The way I am trying to do this is with two arrays, where each array is representative of column A and column B. Below is what I have.
Sub UserFormTest()
Dim i As Variant
Dim h As Variant
Dim j() As Variant
Dim k As Integer
Dim l As Integer
Dim m() As Variant
k = Application.WorksheetFunction.Count(Sheet1.Range("g5:g10000")) + 4
l = Application.WorksheetFunction.Count(Sheet1.Range("m5:m10000")) + 4
'Here I'm trying to allocate value to the arrays
j = Range(Cells(5, 7), Cells(k, 7))
m = Range(Cells(5, 13), Cells(l, 13))
'This is where I just want to loop through rank i of array(m) through all of the ranks of array(j)
For i = 1 To UBound(m)
For h = 1 To UBound(j)
If m(i) = j(h) Then
Sheet1.Range(Cells(4 + i, 13)).Value = Sheet1.Range(Cells(4 + h, 7)).Value
End If
Next h
Next i
'Test Cells to make sure my UBound objects are behaving correctly
Sheet1.Cells(30, 3).Value = UBound(j)
Sheet1.Cells(31, 3).Value = UBound(m)
End Sub
I'm getting an error '9', Subscript out of range error
If anyone can help me out on this, I'll greatly appreciate it. This forum has really assisted me with getting my feet wet with VBA.
Thanks,
Bob
Bookmarks