reportingbuzz
MIS
Hi,
How can I loop through a range? Within the loop, I wish to find the value. If it exists, then get the cell reference of the that value? How can do this too?
My code now is:
Any suggestions appreciated.
Thanks.
How can I loop through a range? Within the loop, I wish to find the value. If it exists, then get the cell reference of the that value? How can do this too?
My code now is:
Code:
For i = 0 To UBound(aPlan, 2)
'Take the value of the C_Plan of the i row and dump it into a variable.
varPlan = aPlan(C_Plan, i)
'MsgBox (Count & "." & varPlan)
'Loop through the PlanUIs sheet (specifically column 'B')
'and find the associated UniqueIdentifier (which exists in column 'A'
'Specify the name of worksheet, range of the worksheet to find the value
Set myRng = Worksheets("PlanUIs").Range("B2:B105")
'For Each cel In myRng
For iRow = 1 To myRng.Count
'If cel.Value = varPlan Then
If myRng.Cells.Value = varPlan Then
MsgBox (varPlan)
'Since the value exists, get the cell reference of the matched value.
'Reference would point to B(RowNumber)
'Get the reference to the A column which would be A(RowNumber)
'Now get the UniqueIdentifier of the A(RowNumber)
'Insert this value into the worksheet - Plan_PlanComponent_Link into cell A2
End If
Next
'Next cel
'see if there is a value in the Booking columns of the array - aPlan
varBookings = aPlan(C_Bookings, i)
Count = Count + 1
Next
Any suggestions appreciated.
Thanks.