I have a UserForm for updating details on a sheet by searching for a reference in a range and updating the cell to the right of that using offset. I'm using this method to elimate the dreaded human error factor.
I found the below code down the back of the internet and have adapted it to suit my workbook. It uses a string (in TextBox_Reference) and searches in column R and stamps the value from Textbox_Date to the corresponding cell (next column over).
I need to somehow adapt this so if it doesn't find the value in column R it checks V and then Z and then AD. In reality there will be many columns to check.
Could someone please help me amend this so it searches through a non-contiguous range?
Each column in the range will start from row 2 and end at the same "LastRow" which is defined earlier in the code.
Many thanks in advance.
Kerry.
Dim FindString As String
Dim Rng As Range
FindString = TextBox_IssueReference
If Trim(FindString) <> "" Then
With Sheets("Daily Data").Range("R2:R" & LastRow)
Set Rng = .Find(What:=FindString, _
After:=.Cells(.Cells.Count), _
LookIn:=xlValues, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)
If Not Rng Is Nothing Then
Rng.Offset(0, 1) = CDate(TextBox_Date)
Else
MsgBox "Reference not found."
End If
End With
End If
Bookmarks