MisterProzilla
Active Member
- Joined
- Nov 12, 2015
- Messages
- 264
Hi everyone,
I have two sheets listing staff names, one for a broad overview and one specifically for tracking long-term sickness. When staff attend a review meeting in the long-term sheet, details are entered in a designated form-ish area, then the staff row is clicked and the 'Add Review' button is clicked, then it updates relevant fields in the selected staff row. That all works fine.
What I'd also like it to do is update the overview sheet with the meeting review date too. I'm trying to use a Vlookup within VBA to return the target review meeting cell for the matching ID, but I'm not sure if and how you can use vlookup to return a cell reference in this way, or if it just works with values? And if Vlookup won't work for this, is there an alternative?
Here's what I've got - the 'CalR' line in bold is where it's bringing up an error - 'Runtime error 91 - object variable or With block variable not set'.
Any help would be appreciated
I have two sheets listing staff names, one for a broad overview and one specifically for tracking long-term sickness. When staff attend a review meeting in the long-term sheet, details are entered in a designated form-ish area, then the staff row is clicked and the 'Add Review' button is clicked, then it updates relevant fields in the selected staff row. That all works fine.
What I'd also like it to do is update the overview sheet with the meeting review date too. I'm trying to use a Vlookup within VBA to return the target review meeting cell for the matching ID, but I'm not sure if and how you can use vlookup to return a cell reference in this way, or if it just works with values? And if Vlookup won't work for this, is there an alternative?
Here's what I've got - the 'CalR' line in bold is where it's bringing up an error - 'Runtime error 91 - object variable or With block variable not set'.
Any help would be appreciated
Code:
Sub AddReview()
'Enter details of the review meeting in an area at the top of the sheet, then click a staff row and click the button and it updates the staff row's review record as below
Dim CalR As Range
'Looks for the matching ID(B/ActiveRow) in the Calendar sheet (Sheet1) to try and find the cell to enter a review date. In the Calendar, col A is ID, col I is the review dates.
[B]CalR = Application.WorksheetFunction.VLookup(Range("B" & ActiveCell.Row).Value, Sheet1.Range("A11:I300"), 9, False)[/B]
If ActiveCell.Row < 9 Then
MsgBox "Please select a record from the table below", vbOKOnly
Exit Sub
End If
' Copy the Meeting date (E5) into the Most Recent Review cell (F/ActiveRow)
Range("F" & ActiveCell.Row).Value = Range("E5").Value
' If enabled in the Workings sheet(Sheet3), updates the Informal review date cell in the Calendar (Sheet1)
If Sheet3.Range("BJ15").Value = "Yes" Then
CalR.Value = Range("E5").Value
End If
' Copy the meeting details (G6) into the Review dump(G/ActiveRow), with line break, followed by a copy of the current contents (col K)
Range("G" & ActiveCell.Row).Value = Range("G6").Value & Chr(10) & Range("K" & ActiveCell.Row).Value
End Sub
Last edited: