I have been struggling with a change to a worksheet that has affected code that I previously used (see below). The code originally looked at one column and then, based on the value, placed the appropriate text in the subsequent adjacent cells. However, my spreadsheet may now have values in one, two or three columns (D,E and/or F). I have made several attempts at adjusting this code and am getting nowhere fast (mostly due to my lack of skill).
Any suggestions would be enormously appreciated.
Thanks very much. Original code below:
Sub AutoComplete()
'ActiveSheet.Unprotect Password:=""
Dim rngY As Range
Dim rng As Range
Set rngY = Range("D12:D" & Range("D" & Range("A:A").Rows.Count).End(xlUp).Row)
Application.ScreenUpdating = False
Application.EnableEvents = False
For Each rng In rngY
If LCase(rng.Value) = "" Then
rng.Offset(0, 3).Value = ""
ElseIf LCase(rng.Value) = "0" Then
rng.Offset(0, 3).Value = "Not Applicable"
rng.Offset(0, 4).Value = "Not Applicable"
rng.Offset(0, 5).Value = "Not Applicable"
ElseIf LCase(rng.Value) >= 1 Then
rng.Offset(0, 3).Value = "Please Complete"
rng.Offset(0, 4).Value = "Please Complete"
rng.Offset(0, 5).Value = "Outstanding"
End If
Next rng
'ActiveSheet.Protect Password:="", _
'DrawingObjects:=True, Contents:=True, Scenarios:=True
Application.ScreenUpdating = True
Application.EnableEvents = True
End Sub
Bookmarks