sharky12345
Well-known Member
- Joined
- Aug 5, 2010
- Messages
- 3,422
- Office Version
- 2016
- Platform
- Windows
I'm trying to update a column with values depending on a certain criteria using this;
Column N, apart from being updated by this routine, can also be edited manually by the user.
I added the clearcontents part because I wanted to ensure that the routine didn't duplicate the values if the routine was run twice in error, but the problem is that if column N already has a value added manually the routine clears it, so what I need is a way to retain any manually added values and only update the column with the values found with the above criteria, but also ensuring that they are not duplicated if they already exist.
Code:
Sheet14.Range("N4:O23").ClearContents
For Each cell In Sheet14.Range("B4:B23")
If cell <> "" Then
If cell.Offset(0, 2) = "" Then
Else
If cell.Offset(0, 2) = "Constant" Or cell.Offset(0, 2) = "Visit" Or cell.Offset(0, 2) = "Area" Or cell.Offset(0, 2) = "Site" Then
Lastrow = Sheet14.Range("N65536").End(xlUp).Row + 1
Sheet14.Range("N" & Lastrow).Value = cell.Offset(0, 15).Value
Sheet14.Range("O" & Lastrow).Value = cell.Offset(0, 2).Value
End If
End If
End If
Next
Column N, apart from being updated by this routine, can also be edited manually by the user.
I added the clearcontents part because I wanted to ensure that the routine didn't duplicate the values if the routine was run twice in error, but the problem is that if column N already has a value added manually the routine clears it, so what I need is a way to retain any manually added values and only update the column with the values found with the above criteria, but also ensuring that they are not duplicated if they already exist.