Hello Excel_vba,
Here is macro that places the value in column "I" into the variable "X" once the string "Total Costs" has been found in column "B".
Sub FindTest()
Dim RngB As Range
Dim RngEnd As Range
Dim TotalCell As Range
Dim X As Double
'Define the search range from B10 to the last entry in column "B"
Set RngB = Cells(10, "D")
Set RngEnd = Cells(Rows.Count, "B").End(xlUp)
Set RngB = IIf(RngEnd.Row < RngB.Row, RngB, Range(RngB, RngEnd))
'Search column "B" only for the string "Total Costs", case is ignored
Set TotalCell = RngB.Find("Total Costs", , xlValues, xlWhole, xlByRows, xlNext, False)
If Not TotalCell Is Nothing Then
X = TotalCell.Offset(0, 7)
End If
End Sub
Bookmarks