Good day,
I need a little help with a project I'm completing. What I'm trying to do is have a button find a value in column 'B' on the second sheet of the workbook. The value the button is looking for will be user generated in cell C4 of sheet 1. Once the value has been found I want the button to update the cell in the fifth column in the same row with todays date. Right now my issue is with locating the cell I want to be updated. I've searched through multiple message boards, including this one, and have yet to find anything I could use let alone understand.
So far my code looks like so:
The find doesn't work so well. I'm obviously doing something wrong. I designated the value from cell C4 as a string variable as it can, and will, change constantly. I can have todays date entered in a cell but locating the cell in the fifth column for the row where the "TicketNum" variable resides is my big issue. I'm unfamiliar with much of vba sintax. I know I can do a =Match in excel to find the row but how do I have vba do the same and then update the fifth column in that row?
Thank you in advance to anyone who responds.
I need a little help with a project I'm completing. What I'm trying to do is have a button find a value in column 'B' on the second sheet of the workbook. The value the button is looking for will be user generated in cell C4 of sheet 1. Once the value has been found I want the button to update the cell in the fifth column in the same row with todays date. Right now my issue is with locating the cell I want to be updated. I've searched through multiple message boards, including this one, and have yet to find anything I could use let alone understand.
So far my code looks like so:
Code:
Private Sub CommandButton2_Click()
Dim TicketNum As String
Dim strCheck As String
TicketNum = Workbooks("PensionDataCorrection.xls").Sheets(1).Range("C4")
With Workbooks("PensionDataCorrection.xls").Sheets(2).Range("b:b")
On Error Resume Next
strCheck = .Find(what:=TicketNum, After:=Cells(1, 1), LookIn:=xlValues, Lookat:=xlWhole, SearchOrder:=ByRows, SearchDirection:=xlNext, MatchCase:=False).Offset(0, 1)
MsgBox "Value is in column: " & strCheck
On Error GoTo 0
End With
If strCheck <> vbNullString Then
MsgBox "Does Not Exist"
End If
End Sub
The find doesn't work so well. I'm obviously doing something wrong. I designated the value from cell C4 as a string variable as it can, and will, change constantly. I can have todays date entered in a cell but locating the cell in the fifth column for the row where the "TicketNum" variable resides is my big issue. I'm unfamiliar with much of vba sintax. I know I can do a =Match in excel to find the row but how do I have vba do the same and then update the fifth column in that row?
Thank you in advance to anyone who responds.