Hey all,
Hopefully someone can help me with this problem I'm having, as I can't seem to find a solution anywhere online or in the help files that works for me. I'm currently trying to write some code that will search a row for a specific string, and once found, will then look at the cell to the immediate left for a different specific string. If it finds both, it will then copy the contents of the cell 2 rows to the left into a different cell on a seperate sheet. This is what I've come up with so far:
Sub Find_MH()
Dim FindString As String
Dim Rng As Range
FindString = "MH"
If Trim(FindString) <> "" Then
With Sheets("Data").Range("D:D")
Set Rng = .Find(What:=FindString, _
After:=.Cells(.Cells.Count), _
LookIn:=xlValues, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)
If Not Rng Is Nothing And Rng.Offset(0, -1).Value = "Available" Then
Sheet1.Range("B29").Value = Rng.Offset(0, -2).Value
Rng.Offset(0, -1).Value = "Allocated"
Else
MsgBox "No MH Found"
End If
End With
End If
End Sub
That code will search down the D column for the string "MH" and then check for the string "Available" in the adjacent cell. What I can't figure out is how to properly use the FindNext command to keep searching if it doesn't find the "Available" string in the adjacent cell, until both conditions are met, and then execute the other code.
Hopefully I've explained it so that other people can understand what I'm trying to do.
Any help would be greatly appreciated 
Chris
Bookmarks