Hi,
Per a Mr. Excel book: VBA And Macros: Microsoft Excel 2010, I coded the following - which works - but currently requires manual updating of the specified array range in the code when data is added to the bottom of the 2 column table. My question is whether there is a way via code to automatically respecify the range so as to include new data added to the bottom of the table?
Dim Descrip2Array As Variant
Descrip2Array = Worksheets("Description 2 Name").Range("A2:B38")
b = 0
For b = 1 To UBound(Descrip2Array, 1)
If Descrip2Array(b, 1) = CostCenter Then ActiveCell.Value = Descrip2Array(b, 2)
Exit For
End If
Next b
So the range I specified in code extends through Row 38. When we add data past Row 38, is there any way other than manually updating the code to extend the declared range of the array?
Thanks for any help offered.
Brian
Per a Mr. Excel book: VBA And Macros: Microsoft Excel 2010, I coded the following - which works - but currently requires manual updating of the specified array range in the code when data is added to the bottom of the 2 column table. My question is whether there is a way via code to automatically respecify the range so as to include new data added to the bottom of the table?
Dim Descrip2Array As Variant
Descrip2Array = Worksheets("Description 2 Name").Range("A2:B38")
b = 0
For b = 1 To UBound(Descrip2Array, 1)
If Descrip2Array(b, 1) = CostCenter Then ActiveCell.Value = Descrip2Array(b, 2)
Exit For
End If
Next b
So the range I specified in code extends through Row 38. When we add data past Row 38, is there any way other than manually updating the code to extend the declared range of the array?
Thanks for any help offered.
Brian